diff --git a/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt b/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt index 94e9e8eb3..a3d1919bb 100644 --- a/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt +++ b/odinclient/src/main/kotlin/me/odinclient/features/impl/render/EtherWarpHelper.kt @@ -70,7 +70,7 @@ object EtherWarpHelper : Module( if ( etherWarpTriggerBot && tbClock.hasTimePassed(etherWarpTBDelay) && - DungeonUtils.currentFullRoom?.waypoints?.any { etherPos.vec?.equal(it.toVec3()) == true } == true && + DungeonUtils.currentRoom?.waypoints?.any { etherPos.vec?.equal(it.toVec3()) == true } == true && mc.thePlayer.usingEtherWarp ) { tbClock.update() @@ -110,7 +110,7 @@ object EtherWarpHelper : Module( etherWarpHelper && mc.thePlayer.usingEtherWarp ) { - val (_, yaw, pitch) = DungeonUtils.currentFullRoom?.waypoints?.mapNotNull { + val (_, yaw, pitch) = DungeonUtils.currentRoom?.waypoints?.mapNotNull { etherwarpRotateTo(it.toBlockPos()) ?: return@mapNotNull null }?.minByOrNull { val (_, yaw, pitch) = it diff --git a/src/main/kotlin/me/odinmain/commands/impl/DevCommand.kt b/src/main/kotlin/me/odinmain/commands/impl/DevCommand.kt index 2298c6e06..35dac7758 100644 --- a/src/main/kotlin/me/odinmain/commands/impl/DevCommand.kt +++ b/src/main/kotlin/me/odinmain/commands/impl/DevCommand.kt @@ -103,7 +103,7 @@ val devCommand = commodore("oddev") { |DungeonTime: ${DungeonUtils.dungeonTime} |currentDungeonPlayer: ${DungeonUtils.currentDungeonPlayer.name}, ${DungeonUtils.currentDungeonPlayer.clazz}, ${DungeonUtils.currentDungeonPlayer.isDead}, ${DungeonUtils.isGhost} |doorOpener: ${DungeonUtils.doorOpener} - |currentRoom: ${DungeonUtils.currentFullRoom?.room?.data?.name}, roomsPassed: ${DungeonUtils.passedRooms.map { it.room.data.name }} + |currentRoom: ${DungeonUtils.currentRoom?.data?.name}, roomsPassed: ${DungeonUtils.passedRooms.map { it.data.name }} |Teammates: ${DungeonUtils.dungeonTeammates.joinToString { "§${it.clazz.colorCode}${it.name} (${it.clazz} [${it.clazzLvl}])" }} |TeammatesNoSelf: ${DungeonUtils.dungeonTeammatesNoSelf.map { it.name }} |LeapTeammates: ${DungeonUtils.leapTeammates.map { it.name }} @@ -138,7 +138,7 @@ val devCommand = commodore("oddev") { } literal("roomdata").runs { - val room = DungeonUtils.currentFullRoom + val room = DungeonUtils.currentRoom val roomCenter = getRoomCenter(mc.thePlayer.posX.toInt(), mc.thePlayer.posZ.toInt()) val core = ScanUtils.getCore(roomCenter) modMessage( @@ -147,8 +147,8 @@ val devCommand = commodore("oddev") { Middle: ${roomCenter.x}, ${roomCenter.z} Room: ${DungeonUtils.currentRoomName} Core: $core - Rotation: ${room?.room?.rotation ?: "NONE"} - Positions: ${room?.components?.joinToString { "(${it.x}, ${it.z})" } ?: "None"} + Rotation: ${room?.rotation ?: "NONE"} + Positions: ${room?.roomComponents?.joinToString { "(${it.x}, ${it.z})" } ?: "None"} ${getChatBreak()} """.trimIndent(), "") writeToClipboard(core.toString(), "§aCopied $core to clipboard!") @@ -160,7 +160,7 @@ val devCommand = commodore("oddev") { """ ${getChatBreak()} Middle: $block - Relative Coords: ${DungeonUtils.currentFullRoom?.getRelativeCoords(block.toVec3())?.toString()} + Relative Coords: ${DungeonUtils.currentRoom?.getRelativeCoords(block.toVec3())?.toString()} ${getChatBreak()} """.trimIndent(), "") } diff --git a/src/main/kotlin/me/odinmain/events/impl/DungeonEvents.kt b/src/main/kotlin/me/odinmain/events/impl/DungeonEvents.kt index c35e487d5..4c42183de 100644 --- a/src/main/kotlin/me/odinmain/events/impl/DungeonEvents.kt +++ b/src/main/kotlin/me/odinmain/events/impl/DungeonEvents.kt @@ -1,10 +1,9 @@ package me.odinmain.events.impl - -import me.odinmain.utils.skyblock.dungeon.tiles.FullRoom +import me.odinmain.utils.skyblock.dungeon.tiles.Room import net.minecraftforge.fml.common.eventhandler.Event abstract class DungeonEvents : Event() { - class RoomEnterEvent(val fullRoom: FullRoom?) : DungeonEvents() + class RoomEnterEvent(val room: Room?) : DungeonEvents() } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/ExtraStats.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/ExtraStats.kt index ae387d9b9..1a2d135c6 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/ExtraStats.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/ExtraStats.kt @@ -31,7 +31,7 @@ object ExtraStats : Module( modMessage(getCenteredText("§b${extraStats.secretsFound}§r-§6${DungeonUtils.cryptCount}§r-§c${DungeonUtils.deathCount}"), prefix = "") modMessage(getCenteredText(if (DungeonUtils.dungeonTeammatesNoSelf.isNotEmpty()) DungeonUtils.dungeonTeammatesNoSelf.joinToString(separator = "§r, ") { "§${it.clazz.colorCode}${it.name}" } else "§3Solo"), prefix = "") modMessage("", prefix = "") - modMessage(getChatBreak(), prefix = "", chatStyle = createClickStyle(ClickEvent.Action.SUGGEST_COMMAND, "Passed rooms: \n${DungeonUtils.passedRooms.joinToString("\n") { "§a${it.room.data.name}" }}")) + modMessage(getChatBreak(), prefix = "", chatStyle = createClickStyle(ClickEvent.Action.SUGGEST_COMMAND, "Passed rooms: \n${DungeonUtils.passedRooms.joinToString("\n") { "§a${it.data.name}" }}")) } init { diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/DungeonWaypoints.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/DungeonWaypoints.kt index 2a773242a..e6c155a16 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/DungeonWaypoints.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/DungeonWaypoints.kt @@ -22,7 +22,7 @@ import me.odinmain.utils.skyblock.* import me.odinmain.utils.skyblock.dungeon.DungeonUtils import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRelativeCoords -import me.odinmain.utils.skyblock.dungeon.tiles.FullRoom +import me.odinmain.utils.skyblock.dungeon.tiles.Room import net.minecraft.block.BlockSign import net.minecraft.client.gui.GuiButton import net.minecraft.client.gui.GuiScreen @@ -70,9 +70,9 @@ object DungeonWaypoints : Module( var timerSetting: Int by SelectorSetting("Timer Type", TimerType.NONE.displayName, TimerType.getArrayList(), description = "Type of route timer you want to place.").withDependency { !waypointType.equalsOneOf(0, 1, 5) && settingsDropDown } private val resetButton by ActionSetting("Reset Current Room", description = "Resets the waypoints for the current room.") { - val room = DungeonUtils.currentFullRoom ?: return@ActionSetting modMessage("§cRoom not found!") + val room = DungeonUtils.currentRoom ?: return@ActionSetting modMessage("§cRoom not found!") - val waypoints = DungeonWaypointConfig.waypoints.getOrPut(room.room.data.name) { mutableListOf() } + val waypoints = DungeonWaypointConfig.waypoints.getOrPut(room.data.name) { mutableListOf() } if (waypoints.isEmpty()) return@ActionSetting modMessage("§cCurrent room does not have any waypoints!") waypoints.clear() DungeonWaypointConfig.saveConfig() @@ -176,7 +176,7 @@ object DungeonWaypoints : Module( @SubscribeEvent fun onRender(event: RenderWorldLastEvent) { if ((DungeonUtils.inBoss || !DungeonUtils.inDungeons) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return - val room = DungeonUtils.currentFullRoom ?: return + val room = DungeonUtils.currentRoom ?: return startProfile("Dungeon Waypoints") glList = RenderUtils.drawBoxes(room.waypoints, glList, disableDepth) if (renderTitle) { @@ -187,7 +187,7 @@ object DungeonWaypoints : Module( } if (debugWaypoint) { - room.components.forEach { + room.roomComponents.forEach { Renderer.drawBox(Vec3(it.x.toDouble(), 70.0, it.z.toDouble()).toAABB(), Color.GREEN, fillAlpha = 0) } } @@ -205,7 +205,7 @@ object DungeonWaypoints : Module( val sr = ScaledResolution(mc) val pos = reachPosition val (text, editText) = pos?.add(offset)?.let { - val room = DungeonUtils.currentFullRoom ?: return + val room = DungeonUtils.currentRoom ?: return val vec = room.getRelativeCoords(it.add(offset).toVec3()) val waypoint = getWaypoints(room).find { it.toVec3().equal(vec) } @@ -223,7 +223,7 @@ object DungeonWaypoints : Module( @SubscribeEvent fun onMouseInput(event: MouseEvent) { - if (!allowEdits || event.dwheel.sign == 0 || DungeonUtils.currentFullRoom == null) return + if (!allowEdits || event.dwheel.sign == 0 || DungeonUtils.currentRoom == null) return distance = (distance + event.dwheel.sign).coerceIn(0.0, 100.0) event.isCanceled = true } @@ -233,7 +233,7 @@ object DungeonWaypoints : Module( if (mc.thePlayer.usingEtherWarp) { val pos = EtherWarpHelper.getEtherPos(mc.thePlayer.renderVec, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch) if (pos.succeeded && pos.pos != null) { - if (DungeonUtils.currentFullRoom?.waypoints?.any { pos.vec?.equal(it.toVec3()) == true && (it.type == WaypointType.BLOCKETHERWARP) } == true) { + if (DungeonUtils.currentRoom?.waypoints?.any { pos.vec?.equal(it.toVec3()) == true && (it.type == WaypointType.BLOCKETHERWARP) } == true) { event.isCanceled = true return } @@ -246,7 +246,7 @@ object DungeonWaypoints : Module( val offsetPos = pos.add(offset) offset = BlockPos(0.0, 0.0, 0.0) if (isAir(offsetPos) && !allowMidair) return - val room = DungeonUtils.currentFullRoom ?: return + val room = DungeonUtils.currentRoom ?: return val vec = room.getRelativeCoords(offsetPos.toVec3()) val block = getBlockAt(offsetPos) val aabb = @@ -281,7 +281,7 @@ object DungeonWaypoints : Module( @SubscribeEvent fun onNewRoom(event: DungeonEvents.RoomEnterEvent) { glList = -1 - event.fullRoom?.let { setWaypoints(it) } + event.room?.let { setWaypoints(it) } } fun DungeonWaypoint.toVec3() = Vec3(x, y, z) @@ -299,9 +299,9 @@ object DungeonWaypoints : Module( /** * Sets the waypoints for the current room. */ - fun setWaypoints(curRoom: FullRoom) { - curRoom.waypoints = arrayListOf().apply { - DungeonWaypointConfig.waypoints[curRoom.room.data.name]?.let { waypoints -> + fun setWaypoints(curRoom: Room) { + curRoom.waypoints = mutableSetOf().apply { + DungeonWaypointConfig.waypoints[curRoom.data.name]?.let { waypoints -> addAll(waypoints.map { waypoint -> val vec = curRoom.getRealCoords(waypoint.toVec3()) waypoint.copy(x = vec.xCoord, y = vec.yCoord, z = vec.zCoord) @@ -310,9 +310,8 @@ object DungeonWaypoints : Module( } } - fun getWaypoints(room: FullRoom) : MutableList { - return DungeonWaypointConfig.waypoints.getOrPut(room.room.data.name) { mutableListOf() } - } + fun getWaypoints(room: Room) : MutableList = + DungeonWaypointConfig.waypoints.getOrPut(room.data.name) { mutableListOf() } } object GuiSign : GuiScreen() { diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/SecretWaypoints.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/SecretWaypoints.kt index 1c12b4ca1..e0d226d13 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/SecretWaypoints.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/dungeonwaypoints/SecretWaypoints.kt @@ -15,7 +15,7 @@ import me.odinmain.utils.* import me.odinmain.utils.skyblock.devMessage import me.odinmain.utils.skyblock.dungeon.DungeonUtils import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRelativeCoords -import me.odinmain.utils.skyblock.dungeon.tiles.FullRoom +import me.odinmain.utils.skyblock.dungeon.tiles.Room import me.odinmain.utils.skyblock.modMessage import net.minecraft.block.BlockChest import net.minecraft.block.state.IBlockState @@ -30,7 +30,7 @@ object SecretWaypoints { private var lastClicked: BlockPos? = null fun onLocked() { - val room = DungeonUtils.currentFullRoom ?: return + val room = DungeonUtils.currentRoom ?: return getWaypoints(room).find { wp -> wp.toVec3().equal(room.getRelativeCoords(lastClicked?.toVec3() ?: return)) && wp.secret && wp.clicked }?.let { it.clicked = false setWaypoints(room) @@ -53,7 +53,7 @@ object SecretWaypoints { val etherpos = lastEtherPos?.pos?.toVec3() ?: return if (System.currentTimeMillis() - lastEtherTime > 1000) return if (Vec3(packet.x, packet.y, packet.z).distanceTo(etherpos) > 3) return - val room = DungeonUtils.currentFullRoom ?: return + val room = DungeonUtils.currentRoom ?: return val waypoints = getWaypoints(room) waypoints.find { wp -> wp.toVec3().equal(room.getRelativeCoords(etherpos)) && wp.type == WaypointType.ETHERWARP }?.let { handleTimer(it, waypoints, room) @@ -66,7 +66,7 @@ object SecretWaypoints { } private fun clickSecret(pos: Vec3, distance: Int, block: IBlockState? = null) { - val room = DungeonUtils.currentFullRoom ?: return + val room = DungeonUtils.currentRoom ?: return val vec = room.getRelativeCoords(pos) val waypoints = getWaypoints(room) @@ -94,12 +94,12 @@ object SecretWaypoints { room.forEach { it.clicked = false } } - DungeonUtils.currentFullRoom?.let { setWaypoints(it) } + DungeonUtils.currentRoom?.let { setWaypoints(it) } glList = -1 } fun onPosUpdate(pos: Vec3) { - val room = DungeonUtils.currentFullRoom ?: return + val room = DungeonUtils.currentRoom ?: return val waypoints = getWaypoints(room) waypoints.find { wp -> wp.toVec3().addVec(y = 0.5).distanceTo(room.getRelativeCoords(pos)) <= 2 && wp.type == WaypointType.MOVE && !wp.clicked }?.let { wp -> @@ -111,7 +111,7 @@ object SecretWaypoints { } } - private fun handleTimer(waypoint: DungeonWaypoint, waypoints: MutableList, room: FullRoom): Boolean { + private fun handleTimer(waypoint: DungeonWaypoint, waypoints: MutableList, room: Room): Boolean { return when { waypoint.timer == TimerType.START && (routeTimer?.let { System.currentTimeMillis() - it >= 2000 } == true || routeTimer == null) -> { modMessage("${routeTimer?.let { "§2Route timer restarted" } ?: "§aRoute timer started"} ") @@ -121,7 +121,7 @@ object SecretWaypoints { true } waypoint.timer == TimerType.END && routeTimer != null -> { - modMessage("§aRoute took §c${routeTimer?.let { (System.currentTimeMillis() - it)/1000.0 }?.round(2)}§as to complete! §aRoom: §e${room.room.data.name}§a, §aCheckpoints collected: §9${checkpoints}§a${waypoint.title?.let { name -> ", Route: §d$name" } ?: "."}") + modMessage("§aRoute took §c${routeTimer?.let { (System.currentTimeMillis() - it)/1000.0 }?.round(2)}§as to complete! §aRoom: §e${room.data.name}§a, §aCheckpoints collected: §9${checkpoints}§a${waypoint.title?.let { name -> ", Route: §d$name" } ?: "."}") routeTimer = null checkpoints = 0 true diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BeamsSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BeamsSolver.kt index d9aeae6a8..2a2c5755c 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BeamsSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BeamsSolver.kt @@ -11,6 +11,7 @@ import me.odinmain.utils.* import me.odinmain.utils.render.Color import me.odinmain.utils.render.Renderer import me.odinmain.utils.skyblock.dungeon.DungeonUtils +import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords import me.odinmain.utils.skyblock.getBlockIdAt import net.minecraft.init.Blocks import net.minecraft.util.BlockPos @@ -38,15 +39,13 @@ object BeamsSolver { private var currentLanternPairs = ConcurrentHashMap>() - fun onRoomEnter(event: RoomEnterEvent) { - val room = event.fullRoom?.room ?: return // <-- orb = orb.orb - if (room.data.name != "Creeper Beams") return reset() + fun onRoomEnter(event: RoomEnterEvent) = with(event.room) { + if (this?.data?.name != "Creeper Beams") return reset() currentLanternPairs.clear() lanternPairs.forEach { - val pos = room.vec2.addRotationCoords(room.rotation, x = it[0], z = it[2]).let { vec -> BlockPos(vec.x, it[1], vec.z) } - - val pos2 = room.vec2.addRotationCoords(room.rotation, x = it[3], z = it[5]).let { vec -> BlockPos(vec.x, it[4], vec.z) } + val pos = getRealCoords(it[0], it[1], it[2]) + val pos2 = getRealCoords(it[3], it[4], it[5]) if (getBlockIdAt(pos) == 169 && getBlockIdAt(pos2) == 169) currentLanternPairs[pos] = pos2 to colors[currentLanternPairs.size] diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BlazeSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BlazeSolver.kt index 07cc0cf6b..2152b1438 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BlazeSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BlazeSolver.kt @@ -11,7 +11,6 @@ import me.odinmain.utils.skyblock.* import me.odinmain.utils.skyblock.dungeon.* import net.minecraft.entity.item.EntityArmorStand import net.minecraft.util.AxisAlignedBB -import net.minecraft.util.BlockPos import kotlin.collections.set object BlazeSolver { @@ -20,7 +19,7 @@ object BlazeSolver { private var lastBlazeCount = 10 fun getBlaze() { - val room = DungeonUtils.currentFullRoom?.room ?: return + val room = DungeonUtils.currentRoom ?: return if (!DungeonUtils.inDungeons || !room.data.name.equalsOneOf("Lower Blaze", "Higher Blaze")) return val hpMap = mutableMapOf() blazes.clear() @@ -30,8 +29,9 @@ object BlazeSolver { hpMap[entity] = hp blazes.add(entity) } - blazes.sortBy { hpMap[it] } - if (getBlockIdAt(BlockPos(room.x + 1, 118, room.z)) != 4) blazes.reverse() + + if (room.data.name == "Lower Blaze") blazes.sortBy { hpMap[it] } + else blazes.sortByDescending { hpMap[it] } } fun onRenderWorld() { diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BoulderSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BoulderSolver.kt index cdf0d084b..56f6841f5 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BoulderSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/BoulderSolver.kt @@ -31,17 +31,18 @@ object BoulderSolver { } fun onRoomEnter(event: DungeonEvents.RoomEnterEvent) { - val room = event.fullRoom?.room ?: return reset() + val room = event.room ?: return reset() if (room.data.name != "Boulder") return reset() + val roomComponent = room.roomComponents.firstOrNull() ?: return reset() var str = "" for (z in -3..2) { for (x in -3..3) { - room.vec2.addRotationCoords(room.rotation, x * 3, z * 3).let { str += if (getBlockIdAt(BlockPos(it.x, 66, it.z)) == 0) "0" else "1" } + roomComponent.vec3.addRotationCoords(room.rotation, x * 3, z * 3).let { str += if (getBlockIdAt(it.xCoord, 66.0, it.zCoord) == 0) "0" else "1" } } } currentPositions = solutions[str]?.map { sol -> - val render = room.vec2.addRotationCoords(room.rotation, sol[0], sol[1]).let { BlockPos(it.x, 65, it.z) } - val click = room.vec2.addRotationCoords(room.rotation, sol[2], sol[3]).let { BlockPos(it.x, 65, it.z) } + val render = roomComponent.vec3.addRotationCoords(room.rotation, sol[0], sol[1]).let { BlockPos(it.xCoord, 65.0, it.zCoord) } + val click = roomComponent.vec3.addRotationCoords(room.rotation, sol[2], sol[3]).let { BlockPos(it.xCoord, 65.0, it.zCoord) } BoxPosition(render, click) }?.toMutableList() ?: return } diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/IceFillSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/IceFillSolver.kt index 86218efbe..749bda946 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/IceFillSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/IceFillSolver.kt @@ -9,6 +9,7 @@ import me.odinmain.utils.render.Color import me.odinmain.utils.render.Renderer import me.odinmain.utils.skyblock.IceFillFloors import me.odinmain.utils.skyblock.dungeon.DungeonUtils +import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords import me.odinmain.utils.skyblock.dungeon.tiles.Rotations import me.odinmain.utils.skyblock.isAir import me.odinmain.utils.skyblock.modMessage @@ -41,11 +42,10 @@ object IceFillSolver { Renderer.draw3DLine(currentPatterns, color = color, depth = true) } - fun onRoomEnter(event: RoomEnterEvent) { - val room = event.fullRoom?.room ?: return - if (room.data.name != "Ice Fill" || currentPatterns.isNotEmpty()) return + fun onRoomEnter(event: RoomEnterEvent) = with (event.room) { + if (this?.data?.name != "Ice Fill" || currentPatterns.isNotEmpty()) return - scanAllFloors(room.vec3.addRotationCoords(room.rotation, 8), room.rotation) + scanAllFloors(getRealCoords(15, 70, 7).toVec3(), rotation) } private fun scanAllFloors(pos: Vec3, rotation: Rotations) { diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/QuizSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/QuizSolver.kt index 175783c35..6b096b071 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/QuizSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/QuizSolver.kt @@ -7,7 +7,8 @@ import me.odinmain.events.impl.DungeonEvents.RoomEnterEvent import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.quizDepth import me.odinmain.utils.* import me.odinmain.utils.render.* -import net.minecraft.util.Vec3 +import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords +import net.minecraft.util.BlockPos import java.io.InputStreamReader import java.nio.charset.StandardCharsets @@ -18,7 +19,7 @@ object QuizSolver { private var triviaAnswers: List? = null private var triviaOptions: MutableList = MutableList(3) { TriviaAnswer(null, false) } - private data class TriviaAnswer(var vec3: Vec3?, var isCorrect: Boolean) + private data class TriviaAnswer(var blockPos: BlockPos?, var isCorrect: Boolean) init { try { @@ -52,24 +53,21 @@ object QuizSolver { } } - fun onRoomEnter(event: RoomEnterEvent) { - val room = event.fullRoom?.room ?: return - if (room.data.name != "Quiz") return + fun onRoomEnter(event: RoomEnterEvent) = with(event.room) { + if (this?.data?.name != "Quiz") return - room.vec3.addRotationCoords(room.rotation, 0, 6).let { middleAnswerBlock -> - triviaOptions[0].vec3 = middleAnswerBlock.addRotationCoords(room.rotation, -5, 3) - triviaOptions[1].vec3 = middleAnswerBlock - triviaOptions[2].vec3 = middleAnswerBlock.addRotationCoords(room.rotation, 5, 3) - } + triviaOptions[0].blockPos = getRealCoords(BlockPos(20.0, 70.0, 6.0)) + triviaOptions[1].blockPos = getRealCoords(BlockPos(15.0, 70.0, 9.0)) + triviaOptions[2].blockPos = getRealCoords(BlockPos(10.0, 70.0, 6.0)) } fun onRenderWorld() { if (triviaAnswers == null || triviaOptions.isEmpty()) return triviaOptions.forEach { answer -> if (!answer.isCorrect) return@forEach - answer.vec3?.addVec(y= -1)?.let { + answer.blockPos?.add(0.0, -1.0, 0.0)?.let { Renderer.drawBox(it.toAABB(), PuzzleSolvers.quizColor, depth = quizDepth) - RenderUtils.drawBeaconBeam(it, PuzzleSolvers.quizColor, depth = quizDepth) + RenderUtils.drawBeaconBeam(it.toVec3(), PuzzleSolvers.quizColor, depth = quizDepth) } } } diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMazeSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMazeSolver.kt index 7b60ffe11..36ddf3042 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMazeSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TPMazeSolver.kt @@ -10,6 +10,7 @@ import me.odinmain.utils.* import me.odinmain.utils.render.Color import me.odinmain.utils.render.Renderer import me.odinmain.utils.skyblock.dungeon.DungeonUtils +import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords import me.odinmain.utils.skyblock.getBlockAt import net.minecraft.init.Blocks import net.minecraft.network.play.server.S08PacketPlayerPosLook @@ -21,10 +22,10 @@ object TPMazeSolver { private var correctPortals = listOf() private var visited = CopyOnWriteArraySet() - fun onRoomEnter(event: DungeonEvents.RoomEnterEvent) { - val room = event.fullRoom?.room ?: return - if (room.data.name != "Teleport Maze") return - tpPads = BlockPos.getAllInBox(room.vec3.addRotationCoords(room.rotation, -16, -16).addVec(y = -1).toBlockPos(), room.vec3.addRotationCoords(room.rotation, 16, 16).addVec(y = -1).toBlockPos()) + fun onRoomEnter(event: DungeonEvents.RoomEnterEvent) = with(event.room) { + if (this?.data?.name != "Teleport Maze") return + + tpPads = BlockPos.getAllInBox(getRealCoords(BlockPos(0, 69, 0)), getRealCoords(BlockPos(30, 69, 30))) .filter { getBlockAt(it) == Blocks.end_portal_frame }.toSet() } diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TTTSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TTTSolver.kt index 14e9d40eb..a25515900 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TTTSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/TTTSolver.kt @@ -4,7 +4,6 @@ import me.odinmain.OdinMain.mc import me.odinmain.events.impl.DungeonEvents import me.odinmain.events.impl.PostEntityMetadata import me.odinmain.utils.Vec2 -import me.odinmain.utils.addRotationCoords import me.odinmain.utils.render.Color import me.odinmain.utils.render.Renderer import me.odinmain.utils.skyblock.dungeon.DungeonUtils @@ -35,30 +34,30 @@ object TTTSolver { private var toRender: BlockPos? = null fun tttRoomEnter(event: DungeonEvents.RoomEnterEvent) { - val room = event.fullRoom?.room ?: return + val room = event.room ?: return if (room.data.name != "Tic Tac Toe") return - updateBoard(room.vec2.addRotationCoords(room.rotation, 7, 0), room.rotation) + //updateBoard(room.vec2.addRotationCoords(room.rotation, 7, 0), room.rotation) } private fun updateBoard(bottomRight: Vec2, rotations: Rotations) { for (index in 0 until 9) { - val currentSlot = bottomRight.addRotationCoords(rotations, 0, -index / 3).let { BlockPos(it.x.toDouble(), 70.0 + index % 3, it.z.toDouble())} - board[index] = BoardSlot(findSlotState(currentSlot), currentSlot, index % 3, index / 3, - when (index) { - 4 -> BoardPosition.Middle - 0, 2, 6, 8 -> BoardPosition.Corner - else -> BoardPosition.Edge - }) +// val currentSlot = bottomRight.addRotationCoords(rotations, 0, -index / 3).let { BlockPos(it.x.toDouble(), 70.0 + index % 3, it.z.toDouble())} +// board[index] = BoardSlot(findSlotState(currentSlot), currentSlot, index % 3, index / 3, +// when (index) { +// 4 -> BoardPosition.Middle +// 0, 2, 6, 8 -> BoardPosition.Corner +// else -> BoardPosition.Edge +// }) } } fun onMetaData(event: PostEntityMetadata) { - val room = DungeonUtils.currentFullRoom?.room ?: return + val room = DungeonUtils.currentRoom ?: return if (room.data.name != "Tic Tac Toe") return mc.theWorld?.getEntityByID(event.packet.entityId) as? EntityItemFrame ?: return - updateBoard(room.vec2.addRotationCoords(room.rotation, 7, 0), room.rotation) + // updateBoard(room.vec2.addRotationCoords(room.rotation, 7, 0), room.rotation) } fun tttRenderWorld() { diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WaterSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WaterSolver.kt index 6b7aa44d5..8502ccd33 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WaterSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WaterSolver.kt @@ -4,16 +4,15 @@ 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.Vec2 -import me.odinmain.utils.addRotationCoords import me.odinmain.utils.render.Color import me.odinmain.utils.render.RenderUtils.renderVec import me.odinmain.utils.render.Renderer import me.odinmain.utils.skyblock.dungeon.DungeonUtils +import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords import me.odinmain.utils.skyblock.dungeon.tiles.Room -import me.odinmain.utils.skyblock.dungeon.tiles.Rotations import me.odinmain.utils.skyblock.getBlockAt import me.odinmain.utils.skyblock.modMessage +import me.odinmain.utils.toBlockPos import net.minecraft.init.Blocks import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement import net.minecraft.util.BlockPos @@ -35,27 +34,21 @@ object WaterSolver { waterSolutions = JsonParser().parse(isr).asJsonObject } - private var chestPosition: Vec2 = Vec2(0, 0) - private var roomFacing: Rotations = Rotations.NONE private var variant = -1 private var solutions = ConcurrentHashMap>() private var openedWater = -1L - fun scan() { - val room = DungeonUtils.currentFullRoom?.room ?: return - if (room.data.name != "Water Board" || variant != -1) return - solve(room) + fun scan() = with (DungeonUtils.currentRoom) { + if (this?.data?.name != "Water Board" || variant != -1) return + solve(this) } private fun solve(room: Room) { - chestPosition = room.vec2.addRotationCoords(roomFacing, -7) - roomFacing = room.rotation - val extendedSlots = WoolColor.entries.joinToString("") { if (it.isExtended) it.ordinal.toString() else "" }.takeIf { it.length == 3 } ?: return - val pistonHeadPosition = chestPosition.addRotationCoords(roomFacing, -5) + val pistonHeadPosition = room.getRealCoords(Vec3(15.0, 82.0, 27.0)) val foundBlocks = mutableListOf(false, false, false, false, false) - BlockPos.getAllInBox(BlockPos(pistonHeadPosition.x + 1, 78, pistonHeadPosition.z + 1), BlockPos(pistonHeadPosition.x - 1, 77, pistonHeadPosition.z - 1)).forEach { + BlockPos.getAllInBox(BlockPos(pistonHeadPosition.xCoord + 1, 78.0, pistonHeadPosition.zCoord + 1), BlockPos(pistonHeadPosition.xCoord - 1, 77.0, pistonHeadPosition.zCoord - 1)).forEach { when (getBlockAt(it)) { Blocks.gold_block -> foundBlocks[0] = true Blocks.hardened_clay -> foundBlocks[1] = true @@ -73,7 +66,7 @@ object WaterSolver { else -> -1 } - modMessage("Variant: $variant:$extendedSlots:${roomFacing.name}") + modMessage("Variant: $variant:$extendedSlots:${room.rotation.name}") solutions.clear() waterSolutions[variant.toString()].asJsonObject[extendedSlots].asJsonObject.entrySet().forEach { @@ -103,18 +96,15 @@ object WaterSolver { times.drop(lever.i).filter { it != 0.0 } }.sorted() - val first = solutionList.firstOrNull() ?: return + val firstSolution = solutionList.firstOrNull() ?: return - if (PuzzleSolvers.showTracer) Renderer.draw3DLine(listOf(mc.thePlayer.renderVec, Vec3(first.first.leverPos).addVector(.5, .5, .5)), color = PuzzleSolvers.tracerColorFirst, depth = true) + if (PuzzleSolvers.showTracer) Renderer.draw3DLine(listOf(mc.thePlayer.renderVec, firstSolution.first.leverPos.addVector(.5, .5, .5)), color = PuzzleSolvers.tracerColorFirst, depth = true) if (solutionList.size > 1 && PuzzleSolvers.showTracer) { - if (first.first.leverPos != solutionList[1].first.leverPos) { + if (firstSolution.first.leverPos != solutionList[1].first.leverPos) { Renderer.draw3DLine( - listOf(Vec3(solutionList.first().first.leverPos).addVector(0.5, 0.5, 0.5), - Vec3(solutionList[1].first.leverPos).addVector(0.5, 0.5, 0.5)), - color = PuzzleSolvers.tracerColorSecond, - lineWidth = 1.5f, - depth = true + listOf(solutionList.first().first.leverPos.addVector(0.5, 0.5, 0.5), solutionList[1].first.leverPos.addVector(0.5, 0.5, 0.5)), + color = PuzzleSolvers.tracerColorSecond, lineWidth = 1.5f, depth = true ) } } @@ -126,7 +116,7 @@ object WaterSolver { else orderText.plus("${if (orderText.isEmpty()) "" else ", "}${sortedSolutions.indexOf(it) + 1}") } if (showOrder) - Renderer.drawStringInWorld(orderText, Vec3(solution.key.leverPos).addVector(.5, .5, .5), Color.WHITE, scale = .035f) + Renderer.drawStringInWorld(orderText, solution.key.leverPos.addVector(.5, .5, .5), Color.WHITE, scale = .035f) for (i in solution.key.i until solution.value.size) { val time = solution.value[i] @@ -139,7 +129,7 @@ object WaterSolver { else "§a§lCLICK ME!" } - Renderer.drawStringInWorld(displayText, Vec3(solution.key.leverPos).addVector(0.5, (i - solution.key.i) * 0.5 + 1.5, 0.5), Color.WHITE, scale = 0.04f) + Renderer.drawStringInWorld(displayText, solution.key.leverPos.addVector(0.5, (i - solution.key.i) * 0.5 + 1.5, 0.5), Color.WHITE, scale = 0.04f) } } } @@ -154,32 +144,34 @@ object WaterSolver { } fun reset() { - chestPosition = Vec2(0, 0) - roomFacing = Rotations.NONE variant = -1 solutions.clear() openedWater = -1 LeverBlock.entries.forEach { it.i = 0 } } - enum class WoolColor { - PURPLE, ORANGE, BLUE, GREEN, RED; + private enum class WoolColor(val relativePosition: Vec3) { + RED(Vec3(15.0, 56.0, 15.0)), + GREEN(Vec3(15.0, 56.0, 16.0)), + BLUE(Vec3(15.0, 56.0, 17.0)), + ORANGE(Vec3(15.0, 56.0, 18.0)), + PURPLE(Vec3(15.0, 56.0, 19.0)); - val isExtended: Boolean - get() = chestPosition.addRotationCoords(roomFacing, 3 + ordinal).let { getBlockAt(BlockPos(it.x, 56, it.z)) == Blocks.wool } + val isExtended: Boolean get() = + getBlockAt(DungeonUtils.currentRoom?.getRealCoords(relativePosition)?.toBlockPos() ?: BlockPos(0, 0, 0)) == Blocks.wool } - enum class LeverBlock(var i: Int = 0) { - QUARTZ, GOLD, COAL, DIAMOND, EMERALD, CLAY, WATER, NONE; - - val leverPos: BlockPos - get() { - return if (this == WATER) - chestPosition.addRotationCoords(roomFacing, 17).let { BlockPos(it.x, 60, it.z) } - else - chestPosition.addRotationCoords(if (ordinal < 3) roomFacing.rotateY() else roomFacing.rotateYCCW(), 5) - .addRotationCoords(roomFacing, (ordinal % 3 * 5) + 2).let { BlockPos(it.x, 61, it.z) } - } - + private enum class LeverBlock(val relativePosition: Vec3, var i: Int = 0) { + QUARTZ(Vec3(21.0, 61.0, 20.0)), + GOLD(Vec3(21.0, 61.0, 15.0)), + COAL(Vec3(21.0, 61.0, 10.0)), + DIAMOND(Vec3(9.0, 61.0, 20.0)), + EMERALD(Vec3(9.0, 61.0, 15.0)), + CLAY(Vec3(9.0, 61.0, 10.0)), + WATER(Vec3(15.0, 60.0, 5.0)), + NONE(Vec3(0.0, 0.0, 0.0)); + + val leverPos: Vec3 + get() = DungeonUtils.currentRoom?.getRealCoords(relativePosition) ?: Vec3(0.0, 0.0, 0.0) } } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WeirdosSolver.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WeirdosSolver.kt index a70923136..ef7c42e4b 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WeirdosSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/WeirdosSolver.kt @@ -16,10 +16,10 @@ object WeirdosSolver { fun onNPCMessage(npc: String, msg: String) { if (solutions.none { it.matches(msg) } && wrong.none { it.matches(msg) }) return val correctNPC = mc.theWorld?.loadedEntityList?.find { it is EntityArmorStand && it.name.noControlCodes == npc } ?: return - val room = DungeonUtils.currentFullRoom?.room ?: return + val room = DungeonUtils.currentRoom ?: return val pos = Vec3(correctNPC.posX - 0.5, 69.0, correctNPC.posZ - 0.5).addRotationCoords(room.rotation, -1, 0) - if (solutions.any {it.matches(msg) }) { + if (solutions.any { it.matches(msg) }) { correctPos = pos PlayerUtils.playLoudSound("note.pling", 2f, 1f) } else wrongPositions.add(pos) diff --git a/src/main/kotlin/me/odinmain/utils/VecUtils.kt b/src/main/kotlin/me/odinmain/utils/VecUtils.kt index 99144d569..4f60b40f7 100644 --- a/src/main/kotlin/me/odinmain/utils/VecUtils.kt +++ b/src/main/kotlin/me/odinmain/utils/VecUtils.kt @@ -196,51 +196,6 @@ fun Vec3.rotateToNorth(rotation: Rotations): Vec3 { } } -/** - * Rotates a Vec2 to the given rotation. - * @param rotation The rotation to rotate to - * @return The rotated Vec2 - */ -fun Vec2.addRotationCoords(rotation: Rotations, dist: Int = 4): Vec2 { - return when (rotation) { - Rotations.NORTH -> Vec2(x, z + dist) - Rotations.WEST -> Vec2(x + dist, z) - Rotations.SOUTH -> Vec2(x, z - dist) - Rotations.EAST -> Vec2(x - dist, z) - Rotations.NONE -> this - } -} - -fun Vec3.addRotationCoords(rotations: Rotations, dist: Int = 4): Vec3 { - return when (rotations) { - Rotations.NORTH -> Vec3(this.xCoord, this.yCoord, this.zCoord + dist) - Rotations.WEST -> Vec3(this.xCoord + dist, this.yCoord, this.zCoord) - Rotations.SOUTH -> Vec3(this.xCoord, this.yCoord, this.zCoord - dist) - Rotations.EAST -> Vec3(this.xCoord - dist, this.yCoord, this.zCoord) - Rotations.NONE -> this - } -} - -fun Vec2.addRotationCoords(rotation: Rotations, x: Number = 0, z: Number = 0): Vec2 { - return when(rotation){ - Rotations.NORTH -> Vec2(this.x + x.toInt(), this.z + z.toInt()) - Rotations.WEST -> Vec2(this.x + z.toInt(), this.z - x.toInt()) - Rotations.SOUTH -> Vec2(this.x - x.toInt(), this.z - z.toInt()) - Rotations.EAST -> Vec2(this.x - z.toInt(), this.z + x.toInt()) - Rotations.NONE -> this - } -} - -fun Vec3.addRotationCoords(rotation: Rotations, x: Number = 0, z: Number = 0): Vec3 { - return when(rotation){ - Rotations.NORTH -> Vec3(this.xCoord + x.toDouble(), this.yCoord, this.zCoord + z.toDouble()) - Rotations.WEST -> Vec3(this.xCoord + z.toDouble(), this.yCoord, this.zCoord - x.toDouble()) - Rotations.SOUTH -> Vec3(this.xCoord - x.toDouble(), this.yCoord, this.zCoord - z.toDouble()) - Rotations.EAST -> Vec3(this.xCoord - z.toDouble(), this.yCoord, this.zCoord + x.toDouble()) - Rotations.NONE -> this - } -} - /** * Checks if an axis-aligned bounding box (AABB) is interceptable based on the player's position, range, yaw, and pitch. * @@ -648,4 +603,14 @@ fun wrapAngle(angle: Float): Float { fun bezier(t: Float, initial: Float, p1: Float, p2: Float, final: Float): Float { return (1 - t).pow(3) * initial + 3 * (1 - t).pow(2) * t * p1 + 3 * (1 - t) * t.pow(2) * p2 + t.pow(3) * final +} + +fun Vec3.addRotationCoords(rotation: Rotations, x: Int, z: Int): Vec3 { + return when (rotation) { + Rotations.NORTH -> Vec3(this.xCoord + x, this.yCoord, this.zCoord + z) + Rotations.WEST -> Vec3(this.xCoord + z, this.yCoord, this.zCoord - x) + Rotations.SOUTH -> Vec3(this.xCoord - x, this.yCoord, this.zCoord - z) + Rotations.EAST -> Vec3(this.xCoord - z, this.yCoord, this.zCoord + x) + else -> this + } } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/WorldUtils.kt b/src/main/kotlin/me/odinmain/utils/skyblock/WorldUtils.kt index 743b2ac89..5689aa4ee 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/WorldUtils.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/WorldUtils.kt @@ -16,6 +16,10 @@ fun getBlockIdAt(blockPos: BlockPos): Int? { return Block.getIdFromBlock(getBlockStateAt(blockPos).block ?: return null) } +fun getBlockIdAt(x: Double, y: Double, z: Double): Int? { + return getBlockIdAt(BlockPos(x, y, z)) +} + /** * Checks if the block at the specified `BlockPos` is considered "air" in the Minecraft world. * diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/Dungeon.kt b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/Dungeon.kt index 7128bd5e6..acccd1763 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/Dungeon.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/Dungeon.kt @@ -15,7 +15,7 @@ import me.odinmain.utils.skyblock.PlayerUtils.posX import me.odinmain.utils.skyblock.PlayerUtils.posZ import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getDungeonPuzzles import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getDungeonTeammates -import me.odinmain.utils.skyblock.dungeon.tiles.FullRoom +import me.odinmain.utils.skyblock.dungeon.tiles.Room import net.minecraft.entity.player.EntityPlayer import net.minecraft.network.play.server.* import net.minecraftforge.event.entity.EntityJoinWorldEvent @@ -31,8 +31,8 @@ class Dungeon(val floor: Floor) { var dungeonTeammatesNoSelf: ArrayList = ArrayList(4) var leapTeammates: ArrayList = ArrayList(4) var dungeonStats = DungeonStats() - val currentFullRoom: FullRoom? get() = ScanUtils.currentFullRoom - val passedRooms: MutableSet get() = ScanUtils.passedRooms + val currentRoom: Room? get() = ScanUtils.currentRoom + val passedRooms: MutableSet get() = ScanUtils.passedRooms var puzzles = listOf() private fun getBoss(): Boolean { @@ -54,8 +54,9 @@ class Dungeon(val floor: Floor) { } fun enterDungeonRoom(event: RoomEnterEvent) { - val room = event.fullRoom?.takeUnless { room -> passedRooms.any { it.room.data.name == room.room.data.name } } ?: return - dungeonStats.knownSecrets = dungeonStats.knownSecrets?.plus(room.room.data.secrets) ?: room.room.data.secrets + val room = event.room?.takeUnless { room -> passedRooms.any { it.data.name == room.data.name } } ?: return + val roomSecrets = room.data.secrets + dungeonStats.knownSecrets = dungeonStats.knownSecrets?.plus(roomSecrets) ?: roomSecrets } fun onPacket(event: PacketReceivedEvent) { diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/DungeonUtils.kt b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/DungeonUtils.kt index bc10e84bc..7b8ec0c3c 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/DungeonUtils.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/DungeonUtils.kt @@ -8,7 +8,7 @@ import me.odinmain.utils.* import me.odinmain.utils.skyblock.* import me.odinmain.utils.skyblock.LocationUtils.currentDungeon import me.odinmain.utils.skyblock.PlayerUtils.posY -import me.odinmain.utils.skyblock.dungeon.tiles.FullRoom +import me.odinmain.utils.skyblock.dungeon.tiles.Room import net.minecraft.block.BlockSkull import net.minecraft.block.state.IBlockState import net.minecraft.init.Blocks @@ -80,7 +80,7 @@ object DungeonUtils { get() = getItemSlot("Haunt", true) != null val currentRoomName: String - get() = currentDungeon?.currentFullRoom?.room?.data?.name ?: "Unknown" + get() = currentDungeon?.currentRoom?.data?.name ?: "Unknown" val dungeonTeammates: ArrayList get() = currentDungeon?.dungeonTeammates ?: ArrayList() @@ -100,10 +100,10 @@ object DungeonUtils { val mimicKilled: Boolean get() = currentDungeon?.dungeonStats?.mimicKilled == true - val currentFullRoom: FullRoom? - get() = currentDungeon?.currentFullRoom + val currentRoom: Room? + get() = currentDungeon?.currentRoom - val passedRooms: Set + val passedRooms: Set get() = currentDungeon?.passedRooms.orEmpty() val isPaul: Boolean @@ -257,8 +257,12 @@ object DungeonUtils { } } - fun FullRoom.getRelativeCoords(pos: Vec3) = pos.subtractVec(x = this.clayPos.x, z = this.clayPos.z).rotateToNorth(this.room.rotation) - fun FullRoom.getRealCoords(pos: Vec3) = pos.rotateAroundNorth(this.room.rotation).addVec(x = this.clayPos.x, z = this.clayPos.z) + fun Room.getRelativeCoords(pos: Vec3) = pos.subtractVec(x = clayPos.x, z = clayPos.z).rotateToNorth(rotation) + fun Room.getRealCoords(pos: Vec3) = pos.rotateAroundNorth(rotation).addVec(x = clayPos.x, z = clayPos.z) + fun Room.getRelativeCoords(pos: BlockPos) = getRelativeCoords(Vec3(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble())).toBlockPos() + fun Room.getRealCoords(pos: BlockPos) = getRealCoords(Vec3(pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble())).toBlockPos() + fun Room.getRelativeCoords(x: Int, y: Int, z: Int) = getRelativeCoords(BlockPos(x.toDouble(), y.toDouble(), z.toDouble())) + fun Room.getRealCoords(x: Int, y: Int, z: Int) = getRealCoords(BlockPos(x.toDouble(), y.toDouble(), z.toDouble())) val dungeonItemDrops = listOf( "Health Potion VIII Splash Potion", "Healing Potion 8 Splash Potion", "Healing Potion VIII Splash Potion", "Healing VIII Splash Potion", "Healing 8 Splash Potion", diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/ScanUtils.kt b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/ScanUtils.kt index 2dbae5131..d942b71c9 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/ScanUtils.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/ScanUtils.kt @@ -22,13 +22,12 @@ import java.io.FileNotFoundException object ScanUtils { private const val ROOM_SIZE_SHIFT = 5 // Since ROOM_SIZE = 32 (2^5) private const val START = -185 - private const val DEFAULT_HEIGHT = 170 private var lastRoomPos: Vec2 = Vec2(0, 0) private val roomList: Set = loadRoomData() - var currentFullRoom: FullRoom? = null + var currentRoom: Room? = null private set - var passedRooms: MutableSet = mutableSetOf() + var passedRooms: MutableSet = mutableSetOf() private set private fun loadRoomData(): Set { @@ -63,55 +62,52 @@ object ScanUtils { if (event.phase != TickEvent.Phase.END || mc.theWorld == null || mc.thePlayer == null) return if ((!inDungeons && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) || inBoss) { - currentFullRoom?.let { RoomEnterEvent(null).postAndCatch() } + currentRoom?.let { RoomEnterEvent(null).postAndCatch() } return } // If not in dungeon or in boss room, return and register current room as null + val roomCenter = getRoomCenter(mc.thePlayer.posX.toInt(), mc.thePlayer.posZ.toInt()) if (roomCenter == lastRoomPos && LocationUtils.currentArea.isArea(Island.SinglePlayer)) return // extra SinglePlayer caching for invalid placed rooms lastRoomPos = roomCenter - passedRooms.find { previousRoom -> previousRoom.components.any { it.vec2 == roomCenter } }?.let { room -> - if (currentFullRoom?.components?.none { it.vec2 == roomCenter } == true) RoomEnterEvent(room).postAndCatch() + passedRooms.find { previousRoom -> previousRoom.roomComponents.any { it.vec2 == roomCenter } }?.let { room -> + if (currentRoom?.roomComponents?.none { it.vec2 == roomCenter } == true) RoomEnterEvent(room).postAndCatch() return } // If room is in passedRooms, post RoomEnterEvent and return only posts Event if room is not in currentFullRoom - scanRoom(roomCenter)?.let { room -> - FullRoom(room, BlockPos(0, 0, 0), findRoomTilesRecursively(room.vec2, room, mutableSetOf()), arrayListOf()).apply { - updateRotation(this) - if (room.rotation != Rotations.NONE) RoomEnterEvent(this).postAndCatch() - } - } + scanRoom(roomCenter)?.let { room -> if (room.rotation != Rotations.NONE) RoomEnterEvent(room).postAndCatch() } } - private fun updateRotation(fullRoom: FullRoom) { - fullRoom.room.rotation = Rotations.entries.dropLast(1).find { rotation -> - fullRoom.components.any { pos -> - BlockPos(pos.x + rotation.x, getTopLayerOfRoom(fullRoom.room.vec2), pos.z + rotation.z).let { blockPos -> - getBlockIdAt(blockPos) == 159 && (fullRoom.components.size == 1 || EnumFacing.HORIZONTALS.all { facing -> + private fun updateRotation(room: Room) { + if (room.data.name == "Fairy") { + room.rotation = Rotations.SOUTH + room.clayPos = room.roomComponents.firstOrNull()?.let { BlockPos(it.x - 15, getTopLayerOfRoom(it.vec2), it.z - 15) } ?: return + return + } + room.rotation = Rotations.entries.dropLast(1).find { rotation -> + room.roomComponents.any { component -> + BlockPos(component.x + rotation.x, getTopLayerOfRoom(component.vec2), component.z + rotation.z).let { blockPos -> + getBlockIdAt(blockPos) == 159 && (room.roomComponents.size == 1 || EnumFacing.HORIZONTALS.all { facing -> getBlockIdAt(blockPos.add(facing.frontOffsetX, 0, facing.frontOffsetZ)).equalsOneOf(159, 0) - }).also { isCorrectClay -> if (isCorrectClay) fullRoom.clayPos = blockPos } + }).also { isCorrectClay -> if (isCorrectClay) room.clayPos = blockPos } } } } ?: Rotations.NONE } - private fun findRoomTilesRecursively(vec2: Vec2, room: Room, visited: MutableSet, tiles: ArrayList = arrayListOf()): ArrayList { - if (vec2 in visited) return tiles - visited.add(vec2) - val core = getCore(vec2) - if (core in room.data.cores) { - tiles.add(ExtraRoom(vec2.x, vec2.z, core)) - EnumFacing.HORIZONTALS.forEach { facing -> - findRoomTilesRecursively(Vec2(vec2.x + (facing.frontOffsetX shl ROOM_SIZE_SHIFT), vec2.z + (facing.frontOffsetZ shl ROOM_SIZE_SHIFT)), room, visited, tiles) - } + private fun scanRoom(vec2: Vec2): Room? = + getCore(vec2).let { core -> getRoomData(core)?.let { Room(data = it, roomComponents = findRoomComponentsRecursively(vec2, it.cores)) }?.apply { updateRotation(this) } } + + private fun findRoomComponentsRecursively(vec2: Vec2, cores: List, visited: MutableSet = mutableSetOf(), tiles: MutableSet = mutableSetOf()): MutableSet { + if (vec2 in visited) return tiles else visited.add(vec2) + tiles.add(RoomComponent(vec2.x, vec2.z, getCore(vec2).takeIf { it in cores } ?: return tiles)) + EnumFacing.HORIZONTALS.forEach { facing -> + findRoomComponentsRecursively(Vec2(vec2.x + (facing.frontOffsetX shl ROOM_SIZE_SHIFT), vec2.z + (facing.frontOffsetZ shl ROOM_SIZE_SHIFT)), cores, visited, tiles) } return tiles } - private fun scanRoom(vec2: Vec2): Room? = - getCore(vec2).let { core -> getRoomData(core)?.let { Room(vec2.x, vec2.z, it, core) } } - private fun getRoomData(hash: Int): RoomData? = roomList.find { hash in it.cores } @@ -144,21 +140,22 @@ object ScanUtils { return sb.toString().hashCode() } - private fun getTopLayerOfRoom(vec2: Vec2, currentHeight: Int = DEFAULT_HEIGHT): Int { - return if ((isAir(BlockPos(vec2.x, currentHeight, vec2.z)) || isGold(BlockPos(vec2.x, currentHeight, vec2.z))) && currentHeight > 70) getTopLayerOfRoom(vec2, currentHeight - 1) else currentHeight + private fun getTopLayerOfRoom(vec2: Vec2): Int { + val height = mc.theWorld?.getChunkFromChunkCoords(vec2.x shr 4, vec2.z shr 4)?.getHeightValue(vec2.x and 15, vec2.z and 15) ?: 0 + return if (isGold(BlockPos(vec2.x, height, vec2.z))) height else height - 1 } @SubscribeEvent fun enterDungeonRoom(event: RoomEnterEvent) { - currentFullRoom = event.fullRoom - if (passedRooms.none { it.room.data.name == currentFullRoom?.room?.data?.name }) passedRooms.add(currentFullRoom ?: return) - devMessage("${event.fullRoom?.room?.data?.name} - ${event.fullRoom?.room?.rotation} || clay: ${event.fullRoom?.clayPos}") + currentRoom = event.room + if (passedRooms.none { it.data.name == currentRoom?.data?.name }) passedRooms.add(currentRoom ?: return) + devMessage("${event.room?.data?.name} - ${event.room?.rotation} || clay: ${event.room?.clayPos}") } @SubscribeEvent fun onWorldLoad(event: WorldEvent.Unload) { passedRooms.clear() - currentFullRoom = null + currentRoom = null lastRoomPos = Vec2(0, 0) } } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Room.kt b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Room.kt index c31de580f..07f060c21 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Room.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Room.kt @@ -1,18 +1,49 @@ package me.odinmain.utils.skyblock.dungeon.tiles +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonDeserializer +import com.google.gson.JsonElement +import com.google.gson.reflect.TypeToken import me.odinmain.features.impl.dungeon.dungeonwaypoints.DungeonWaypoints.DungeonWaypoint import me.odinmain.utils.Vec2 import net.minecraft.util.BlockPos import net.minecraft.util.Vec3 +import java.lang.reflect.Type +import kotlin.collections.orEmpty -class Room(override val x: Int, override val z: Int, var data: RoomData, var core: Int = 0) : Tile { - var vec2 = Vec2(x, z) - var vec3 = Vec3(x.toDouble(), 70.0, z.toDouble()) - var rotation = Rotations.NONE - override var state: RoomState = RoomState.UNDISCOVERED -} +data class Room( + var rotation: Rotations = Rotations.NONE, + var data: RoomData, + var clayPos: BlockPos = BlockPos(0, 0, 0), + val roomComponents: MutableSet, + var waypoints: MutableSet = mutableSetOf() +) -data class FullRoom(val room: Room, var clayPos: BlockPos, val components: ArrayList, var waypoints: ArrayList) -data class ExtraRoom(val x: Int, val z: Int, val core: Int) { +data class RoomComponent(val x: Int, val z: Int, val core: Int = 0) { val vec2 = Vec2(x, z) + val vec3 = Vec3(x.toDouble(), 70.0, z.toDouble()) +} + +data class RoomData( + val name: String, + val type: RoomType, + val cores: List, + val crypts: Int, + val secrets: Int, + val trappedChests: Int, +) + +class RoomDataDeserializer : JsonDeserializer { + override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): RoomData { + val jsonObject = json?.asJsonObject + val name = jsonObject?.get("name")?.asString ?: "" + val type = context?.deserialize(jsonObject?.get("type"), RoomType::class.java) ?: RoomType.NORMAL + val coresType = object : TypeToken>() {}.type + val cores = context?.deserialize>(jsonObject?.get("cores"), coresType).orEmpty() + val crypts = jsonObject?.get("crypts")?.asInt ?: 0 + val secrets = jsonObject?.get("secrets")?.asInt ?: 0 + val trappedChests = jsonObject?.get("trappedChests")?.asInt ?: 0 + + return RoomData(name, type, cores, crypts, secrets, trappedChests) + } } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/RoomData.kt b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/RoomData.kt deleted file mode 100644 index 57a43e847..000000000 --- a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/RoomData.kt +++ /dev/null @@ -1,29 +0,0 @@ -package me.odinmain.utils.skyblock.dungeon.tiles - -import com.google.gson.* -import com.google.gson.reflect.TypeToken -import java.lang.reflect.Type - -data class RoomData( - val name: String, - val type: RoomType, - val cores: List, - val crypts: Int, - val secrets: Int, - val trappedChests: Int, -) - -class RoomDataDeserializer : JsonDeserializer { - override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): RoomData { - val jsonObject = json?.asJsonObject - val name = jsonObject?.get("name")?.asString ?: "" - val type = context?.deserialize(jsonObject?.get("type"), RoomType::class.java) ?: RoomType.NORMAL - val coresType = object : TypeToken>() {}.type - val cores = context?.deserialize>(jsonObject?.get("cores"), coresType).orEmpty() - val crypts = jsonObject?.get("crypts")?.asInt ?: 0 - val secrets = jsonObject?.get("secrets")?.asInt ?: 0 - val trappedChests = jsonObject?.get("trappedChests")?.asInt ?: 0 - - return RoomData(name, type, cores, crypts, secrets, trappedChests) - } -} \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Rotations.kt b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Rotations.kt index 8d443c4cd..483395e40 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Rotations.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/dungeon/tiles/Rotations.kt @@ -9,37 +9,4 @@ enum class Rotations( WEST(15, -15), EAST(-15, 15), NONE(0, 0); - - - - fun rotateY(): Rotations { - return when (this) { - NORTH -> EAST - EAST -> SOUTH - SOUTH -> WEST - WEST -> NORTH - else -> throw IllegalStateException("Unable to get Y-rotated facing of $this") - } - } - - fun rotateYCCW(): Rotations { - return when (this) { - NORTH -> WEST - EAST -> NORTH - SOUTH -> EAST - WEST -> SOUTH - else -> throw IllegalStateException("Unable to get CCW facing of $this") - } - } - - fun opposite(): Rotations { - return when (this) { - NORTH -> SOUTH - SOUTH -> NORTH - WEST -> EAST - EAST -> WEST - NONE -> NONE - } - } -} - +} \ No newline at end of file diff --git a/src/main/resources/creeperBeamsSolutions.json b/src/main/resources/creeperBeamsSolutions.json index 92521dd7a..57e42a0a4 100644 --- a/src/main/resources/creeperBeamsSolutions.json +++ b/src/main/resources/creeperBeamsSolutions.json @@ -1,27 +1,27 @@ [ - [0, 74, 0, 0, 84, 2], + [15, 74, 15, 15, 84, 13], - [0, 78, 12, 0, 76, -12], + [15, 78, 3, 15, 76, 27], - [-7, 80, -7, 11, 72, 7], + [22, 80, 22, 4, 72, 8], - [-9, 77, 8, 10, 76, -9], + [24, 77, 7, 5, 76, 24], - [-12, 78, 1, 13, 75, -1], + [27, 78, 14, 2, 75, 16], - [-11, 78, 3, 12, 76, -3], + [26, 78, 12, 3, 76, 18], - [-10, 79, -6, 11, 75, 6], + [25, 79, 21, 4, 75, 9], - [-10, 76, -8, 9, 74, 10], + [25, 76, 23, 6, 74, 5], - [-3, 82, 7, 5, 69, -12], + [18, 82, 8, 10, 69, 27], - [-3, 81, -6, 6, 69, 12], + [18, 81, 21, 9, 69, 3], - [6, 81, -5, -11, 70, 8], + [9, 81, 20, 26, 70, 7], - [-3, 81, -6, 6, 69, 12], + [18, 81, 21, 9, 69, 3], - [12, 76, -3, -11, 78, 3] + [3, 76, 18, 26, 78, 12] ] \ No newline at end of file