Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Room scanning refactor #127

Merged
merged 12 commits into from
Nov 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions odinmain/src/main/kotlin/me/odinmain/commands/impl/DevCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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})" }}
|TeammatesNoSelf: ${DungeonUtils.dungeonTeammatesNoSelf.map { it.name }}
|LeapTeammates: ${DungeonUtils.leapTeammates.map { it.name }}
Expand Down Expand Up @@ -140,7 +140,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(
Expand All @@ -149,8 +149,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!")
Expand All @@ -162,7 +162,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(), "")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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
Expand Down Expand Up @@ -71,9 +71,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()
Expand Down Expand Up @@ -164,7 +164,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) {
Expand All @@ -175,7 +175,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)
}
}
Expand Down Expand Up @@ -206,7 +206,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
}
Expand All @@ -219,7 +219,7 @@ object DungeonWaypoints : Module(
val offsetPos = pos.add(offset)
offset = BlockPos(0.0, 0.0, 0.0)
if (isAir(offsetPos)) return
val room = DungeonUtils.currentFullRoom ?: return
val room = DungeonUtils.currentRoom ?: return
val vec = room.getRelativeCoords(offsetPos.toVec3())
val block = getBlockAt(offsetPos)
val aabb =
Expand Down Expand Up @@ -264,7 +264,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)
Expand All @@ -282,9 +282,9 @@ object DungeonWaypoints : Module(
/**
* Sets the waypoints for the current room.
*/
fun setWaypoints(curRoom: FullRoom) {
curRoom.waypoints = arrayListOf<DungeonWaypoint>().apply {
DungeonWaypointConfig.waypoints[curRoom.room.data.name]?.let { waypoints ->
fun setWaypoints(curRoom: Room) {
curRoom.waypoints = mutableSetOf<DungeonWaypoint>().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)
Expand All @@ -293,9 +293,8 @@ object DungeonWaypoints : Module(
}
}

fun getWaypoints(room: FullRoom) : MutableList<DungeonWaypoint> {
return DungeonWaypointConfig.waypoints.getOrPut(room.room.data.name) { mutableListOf() }
}
fun getWaypoints(room: Room) : MutableList<DungeonWaypoint> =
DungeonWaypointConfig.waypoints.getOrPut(room.data.name) { mutableListOf() }
}

object GuiSign : GuiScreen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -91,12 +91,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 ->
Expand All @@ -108,7 +108,7 @@ object SecretWaypoints {
}
}

private fun handleTimer(waypoint: DungeonWaypoint, waypoints: MutableList<DungeonWaypoint>, room: FullRoom): Boolean {
private fun handleTimer(waypoint: DungeonWaypoint, waypoints: MutableList<DungeonWaypoint>, 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"} ")
Expand All @@ -118,7 +118,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,14 +40,13 @@ object BeamsSolver {
private var currentLanternPairs = ConcurrentHashMap<BlockPos, Pair<BlockPos, Color>>()

fun enterDungeonRoom(event: RoomEnterEvent) {
val room = event.fullRoom?.room ?: return // <-- orb = orb.orb
val room = event.room ?: return
if (room.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 = room.getRealCoords(BlockPos(it[0], it[1], it[2])).toBlockPos()
odtheking marked this conversation as resolved.
Show resolved Hide resolved
val pos2 = room.getRealCoords(BlockPos(it[3], it[4], it[5])).toBlockPos()

if (getBlockIdAt(pos) == 169 && getBlockIdAt(pos2) == 169)
currentLanternPairs[pos] = pos2 to colors[currentLanternPairs.size]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<EntityArmorStand, Int>()
blazes.clear()
Expand All @@ -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 renderBlazes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(BlockPos(it.xCoord, 66.0, it.zCoord)) == 0) "0" else "1" }
odtheking marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,10 +43,10 @@ object IceFillSolver {
}

fun enterDungeonRoom(event: RoomEnterEvent) {
val room = event.fullRoom?.room ?: return
val room = event.room ?: return
if (room.data.name != "Ice Fill" || currentPatterns.isNotEmpty()) return

scanAllFloors(room.vec3.addRotationCoords(room.rotation, 8), room.rotation)
scanAllFloors(room.getRealCoords(Vec3(15.0, 70.0, 7.0)), room.rotation)
odtheking marked this conversation as resolved.
Show resolved Hide resolved
}

private fun scanAllFloors(pos: Vec3, rotation: Rotations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.quizDepth
import me.odinmain.utils.*
import me.odinmain.utils.render.*
import me.odinmain.utils.skyblock.dungeon.DungeonUtils
import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords
import net.minecraft.util.Vec3
import java.io.InputStreamReader
import java.nio.charset.StandardCharsets
Expand Down Expand Up @@ -54,14 +55,12 @@ object QuizSolver {
}

fun enterRoomQuiz(event: RoomEnterEvent) {
val room = event.fullRoom?.room ?: return
val room = event.room ?: return
odtheking marked this conversation as resolved.
Show resolved Hide resolved
if (room.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].vec3 = room.getRealCoords(Vec3(20.0, 70.0, 6.0))
odtheking marked this conversation as resolved.
Show resolved Hide resolved
triviaOptions[1].vec3 = room.getRealCoords(Vec3(15.0, 70.0, 9.0))
triviaOptions[2].vec3 = room.getRealCoords(Vec3(10.0, 70.0, 6.0))
}

fun renderWorldLastQuiz() {
Expand Down
Loading
Loading