Skip to content

Commit

Permalink
Fixed WaterSolver not registering clicks
Browse files Browse the repository at this point in the history
Added support for Mineshaft island
Made Puzzles work in SinglePlayer
  • Loading branch information
odtheking committed Nov 6, 2024
1 parent 5306d4f commit 583be52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha
import me.odinmain.utils.profile
import me.odinmain.utils.render.Color
import me.odinmain.utils.render.Renderer
import me.odinmain.utils.skyblock.Island
import me.odinmain.utils.skyblock.LocationUtils
import me.odinmain.utils.skyblock.dungeon.DungeonUtils.inBoss
import me.odinmain.utils.skyblock.dungeon.DungeonUtils.inDungeons
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
Expand Down Expand Up @@ -101,18 +103,18 @@ object PuzzleSolvers : Module(

init {
execute(500) {
if (!inDungeons || inBoss) return@execute
if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return@execute
if (waterSolver) WaterSolver.scan()
if (blazeSolver) BlazeSolver.getBlaze()
}

onPacket(S08PacketPlayerPosLook::class.java) {
if (!inDungeons || inBoss) return@onPacket
if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return@onPacket
if (tpMaze) TPMazeSolver.tpPacket(it)
}

onPacket(C08PacketPlayerBlockPlacement::class.java, { enabled && (waterSolver || boulderSolver) }) {
if (!inDungeons || inBoss) return@onPacket
onPacket(C08PacketPlayerBlockPlacement::class.java) {
if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return@onPacket
if (waterSolver) waterInteract(it)
if (boulderSolver) BoulderSolver.playerInteract(it)
}
Expand Down Expand Up @@ -141,7 +143,7 @@ object PuzzleSolvers : Module(

@SubscribeEvent
fun onWorldRender(event: RenderWorldLastEvent) {
if (!inDungeons || inBoss) return
if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return
profile("Puzzle Solvers Render") {
if (waterSolver) WaterSolver.waterRender()
if (tpMaze) TPMazeSolver.tpRender()
Expand All @@ -165,7 +167,7 @@ object PuzzleSolvers : Module(

@SubscribeEvent
fun blockUpdateEvent(event: BlockChangeEvent) {
if (!inDungeons || inBoss) return
if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return
if (beamsSolver) BeamsSolver.onBlockChange(event)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.gson.JsonObject
import com.google.gson.JsonParser
import me.odinmain.OdinMain.mc
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.showOrder
import me.odinmain.utils.equal
import me.odinmain.utils.render.Color
import me.odinmain.utils.render.RenderUtils.renderVec
import me.odinmain.utils.render.Renderer
Expand All @@ -13,6 +14,7 @@ import me.odinmain.utils.skyblock.dungeon.tiles.Room
import me.odinmain.utils.skyblock.getBlockAt
import me.odinmain.utils.skyblock.modMessage
import me.odinmain.utils.toBlockPos
import me.odinmain.utils.toVec3
import net.minecraft.init.Blocks
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
import net.minecraft.util.BlockPos
Expand All @@ -39,10 +41,11 @@ object WaterSolver {
private var openedWater = -1L

fun scan() = with (DungeonUtils.currentRoom) {
if (this?.data?.name == "Water Board" && variant == -1) solve(this)
if (this?.data?.name == "Water Board" && variant == -1) solve(this)
}

private fun solve(room: Room) {
modMessage("Solving Water Board")
val extendedSlots = WoolColor.entries.joinToString("") { if (it.isExtended) it.ordinal.toString() else "" }.takeIf { it.length == 3 } ?: return

val pistonHeadPosition = room.getRealCoords(Vec3(15.0, 82.0, 27.0))
Expand Down Expand Up @@ -135,7 +138,7 @@ object WaterSolver {

fun waterInteract(event: C08PacketPlayerBlockPlacement) {
if (solutions.isEmpty()) return
LeverBlock.entries.find { it.leverPos == event.position }?.let {
LeverBlock.entries.find { it.leverPos.equal(event.position.toVec3()) }?.let {
it.i++
if (it != LeverBlock.WATER || openedWater != -1L) return
openedWater = System.currentTimeMillis()
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/me/odinmain/utils/skyblock/Island.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum class Island(val displayName: String) {
DarkAuction("Dark Auction"),
JerryWorkshop("Jerry's Workshop"),
Kuudra("Kuudra"),
Mineshaft("Mineshaft"),
Unknown("(Unknown)");

fun isArea(area: Island): Boolean = this == area
Expand Down

0 comments on commit 583be52

Please sign in to comment.