diff --git a/odinclient/src/main/java/me/odinclient/mixin/mixins/entity/MixinEntityRenderer.java b/odinclient/src/main/java/me/odinclient/mixin/mixins/entity/MixinEntityRenderer.java index 534cec87d..3e29520bd 100644 --- a/odinclient/src/main/java/me/odinclient/mixin/mixins/entity/MixinEntityRenderer.java +++ b/odinclient/src/main/java/me/odinclient/mixin/mixins/entity/MixinEntityRenderer.java @@ -34,42 +34,33 @@ private void drawHud(float partialTicks, long nanoTime, CallbackInfo ci) { @Redirect(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;setAngles(FF)V")) private void lockPlayerLooking(EntityPlayerSP instance, float x, float y) { - if (!Camera.INSTANCE.getFreelookToggled()) instance.setAngles(x, y); + if (!Camera.getFreelookToggled()) instance.setAngles(x, y); } @Inject(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;setAngles(FF)V", ordinal = 1), locals = LocalCapture.CAPTURE_FAILSOFT) private void updateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci, boolean flag, float f, float f1, float f2, float f3) { - if (Camera.INSTANCE.getEnabled()) Camera.INSTANCE.updateCameraAndRender(f2, f3); + if (Camera.INSTANCE.getEnabled()) Camera.updateCameraAndRender(f2, f3); } - @Shadow private Minecraft mc; - @Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V", ordinal = 2)) public void orientCamera(float x, float y, float z, float partialTicks){ - if (Camera.INSTANCE.getFreelookToggled()) { - GlStateManager.translate( - 0.0F, 0.0F, -Camera.INSTANCE.calculateCameraDistance( - RenderUtils.INSTANCE.getRenderX(mc.thePlayer), - RenderUtils.INSTANCE.getRenderY(mc.thePlayer) + VecUtilsKt.fastEyeHeight(), - RenderUtils.INSTANCE.getRenderZ(mc.thePlayer), - Camera.INSTANCE.getCameraDistance()) - ); - } else GlStateManager.translate(x, y, z); + if (Camera.getFreelookToggled()) GlStateManager.translate(0.0F, 0.0F, -Camera.calculateCameraDistance()); + else GlStateManager.translate(x, y, z); } @Redirect(method = {"orientCamera"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistance:F")) public float tweakThirdPersonDistance(EntityRenderer instance) { - return Camera.INSTANCE.getCameraDistance(); + return Camera.getCameraDistance(); } @Redirect(method = {"orientCamera"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistanceTemp:F")) public float tweakThirdPersonDistanceTemp(EntityRenderer instance) { - return Camera.INSTANCE.getCameraDistance(); + return Camera.getCameraDistance(); } @ModifyConstant(method = "orientCamera", constant = @Constant(intValue = 8)) public int cameraClip(int constant) { - return Camera.INSTANCE.getCameraClipEnabled() ? 0: constant; + return Camera.getCameraClipEnabled() ? 0: constant; } @Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true) diff --git a/odinclient/src/main/kotlin/me/odinclient/features/impl/render/Camera.kt b/odinclient/src/main/kotlin/me/odinclient/features/impl/render/Camera.kt index 88d5c0be0..be59a16ef 100644 --- a/odinclient/src/main/kotlin/me/odinclient/features/impl/render/Camera.kt +++ b/odinclient/src/main/kotlin/me/odinclient/features/impl/render/Camera.kt @@ -7,6 +7,7 @@ import me.odinmain.features.settings.impl.BooleanSetting import me.odinmain.features.settings.impl.DropdownSetting import me.odinmain.features.settings.impl.KeybindSetting import me.odinmain.features.settings.impl.NumberSetting +import me.odinmain.utils.getPositionEyes import net.minecraft.util.MathHelper import net.minecraft.util.Vec3 import net.minecraftforge.client.event.EntityViewRenderEvent @@ -33,6 +34,7 @@ object Camera : Module( if (!freelookToggled && enabled) enable() else if ((toggle || !enabled) && freelookToggled) disable() } + @JvmStatic var freelookToggled = false private var cameraYaw = 0f private var cameraPitch = 0f @@ -50,10 +52,12 @@ object Camera : Module( super.onDisable() } + @JvmStatic fun getCameraDistance(): Float { return if (enabled) cameraDist else 4f } + @JvmStatic fun getCameraClipEnabled(): Boolean { return if (enabled) cameraClip else false } @@ -90,14 +94,17 @@ object Camera : Module( e.pitch = cameraPitch } + @JvmStatic fun updateCameraAndRender(f2: Float, f3: Float) { if (!freelookToggled) return cameraYaw += f2 / 7 cameraPitch = MathHelper.clamp_float((cameraPitch + f3 / 7), -90f, 90f) } - fun calculateCameraDistance(d0: Double, d1: Double, d2: Double, d3: Double): Float { - var dist = d3 + @JvmStatic + fun calculateCameraDistance(): Float { + val eyes = getPositionEyes() + var dist = getCameraDistance() var f2 = cameraPitch if (mc.gameSettings.thirdPersonView == 2) f2 += 180.0f @@ -106,26 +113,23 @@ object Camera : Module( val d5 = (-cos(cameraYaw / 180.0f * Math.PI.toFloat()) * cos(f2 / 180.0f * Math.PI.toFloat())).toDouble() * dist val d6 = (-sin(f2 / 180.0f * Math.PI.toFloat())).toDouble() * dist - for (i in 0..7) { - var f3 = ((i and 1) * 2 - 1).toFloat() - var f4 = ((i shr 1 and 1) * 2 - 1).toFloat() - var f5 = ((i shr 2 and 1) * 2 - 1).toFloat() + repeat(8) { + var f3 = ((it and 1) * 2 - 1).toFloat() + var f4 = ((it shr 1 and 1) * 2 - 1).toFloat() + var f5 = ((it shr 2 and 1) * 2 - 1).toFloat() f3 *= .1f f4 *= .1f f5 *= .1f val movingObjectPosition = mc.theWorld?.rayTraceBlocks( - Vec3(d0 + f3.toDouble(), d1 + f4.toDouble(), d2 + f5.toDouble()), - Vec3(d0 - d4 + f3.toDouble() + f5.toDouble(), d1 - d6 + f4.toDouble(), d2 - d5 + f5.toDouble()) + Vec3(eyes.xCoord + f3.toDouble(), eyes.yCoord + f4.toDouble(), eyes.zCoord + f5.toDouble()), + Vec3(eyes.xCoord - d4 + f3.toDouble() + f5.toDouble(), eyes.yCoord - d6 + f4.toDouble(), eyes.zCoord - d5 + f5.toDouble()) ) if (movingObjectPosition != null) { - val d7 = movingObjectPosition.hitVec.distanceTo(Vec3(d0, d1, d2)) - - if (d7 < dist) { - dist = d7 - } + val d7 = movingObjectPosition.hitVec.distanceTo(Vec3(eyes.xCoord, eyes.yCoord, eyes.zCoord)) + if (d7 < dist) dist = d7.toFloat() } } - return dist.toFloat() + return dist } } \ No newline at end of file diff --git a/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoHarp.kt b/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoHarp.kt index 8154e71d0..3c4d56aa5 100644 --- a/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoHarp.kt +++ b/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/AutoHarp.kt @@ -44,11 +44,11 @@ object AutoHarp : Module( val newHash = container.inventorySlots.subList(0,36).joinToString("") { it?.stack?.displayName ?: "" }.hashCode() if (lastInv == newHash) return lastInv = newHash - for (i in 0..6) { - val slot = container.inventorySlots[37 + i] + repeat(7) { + val slot = container.inventorySlots[37 + it] if ((slot.stack?.item as? ItemBlock)?.block === Blocks.quartz_block) { PlayerUtils.windowClick(slot.slotNumber, PlayerUtils.ClickType.Middle) - break + return } } } diff --git a/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/ChocolateFactory.kt b/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/ChocolateFactory.kt index 721dca560..223a25af9 100644 --- a/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/ChocolateFactory.kt +++ b/odinclient/src/main/kotlin/me/odinclient/features/impl/skyblock/ChocolateFactory.kt @@ -92,14 +92,14 @@ object ChocolateFactory : Module( } found = false var maxValue = 0 - for (i in 0 until 7) { - val worker = workers[i] - if (worker.contains("climbed as far")) continue - val index = worker.indexOfFirst { it?.contains("Cost") == true }.takeIf { it != -1 } ?: continue - val cost = worker[index + 1]?.noControlCodes?.replace(Regex("\\D"), "")?.toIntOrNull() ?: continue - val value = cost / (i + 1).toFloat() + repeat (7) { + val worker = workers[it] + if (worker.contains("climbed as far")) return + val index = worker.indexOfFirst { it?.contains("Cost") == true } ?: return + val cost = worker[index + 1]?.noControlCodes?.replace(Regex("\\D"), "")?.toIntOrNull() ?: return + val value = cost / (it + 1).toFloat() if (value < maxValue || !found) { - bestWorker = 28 + i + bestWorker = 28 + it maxValue = value.toInt() bestCost = cost found = true diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/BloodCamp.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/BloodCamp.kt index 9a06ece1d..ad3245913 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/BloodCamp.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/BloodCamp.kt @@ -74,8 +74,7 @@ object BloodCamp : Module( @SubscribeEvent fun onRenderBossHealth(event: RenderGameOverlayEvent.Pre) { - if (!inDungeons || inBoss || event.type != RenderGameOverlayEvent.ElementType.BOSSHEALTH - || !watcherBar || BossStatus.bossName.noControlCodes != "The Watcher") return + if (!watcherBar || !inDungeons || inBoss || event.type != RenderGameOverlayEvent.ElementType.BOSSHEALTH || BossStatus.bossName.noControlCodes != "The Watcher") return val amount = 12 + DungeonUtils.floor.floorNumber BossStatus.bossName += BossStatus.healthScale.takeIf { it >= 0.05 }?.let { " ${(amount * it).roundToInt()}/$amount" } ?: "" } @@ -108,8 +107,7 @@ object BloodCamp : Module( private fun onPacketLookMove(packet: S17PacketEntityLookMove) { val entity = packet.getEntity(mc.theWorld ?: return) as? EntityArmorStand ?: return - if (currentWatcherEntity?.let { it.getDistanceToEntity(entity) <= 20 } != true || - entity.getEquipmentInSlot(4)?.item != Items.skull || getSkullValue(entity) !in allowedMobSkulls) return + if (currentWatcherEntity?.let { it.getDistanceToEntity(entity) <= 20 } != true || entity.getEquipmentInSlot(4)?.item != Items.skull || getSkullValue(entity) !in allowedMobSkulls) return val packetVector = Vec3( (entity.serverPosX + packet.func_149062_c()) / 32.0, @@ -121,16 +119,14 @@ object BloodCamp : Module( val data = entityDataMap[entity] ?: return val timeTook = currentTickTime - data.started - val startVector = data.startVector + val time = getTime(data.firstSpawns, timeTook) val speedVectors = Vec3( - (packetVector.xCoord - startVector.xCoord) / timeTook, - (packetVector.yCoord - startVector.yCoord) / timeTook, - (packetVector.zCoord - startVector.zCoord) / timeTook, + (packetVector.xCoord - data.startVector.xCoord) / timeTook, + (packetVector.yCoord - data.startVector.yCoord) / timeTook, + (packetVector.zCoord - data.startVector.zCoord) / timeTook, ) - val time = getTime(data.firstSpawns, timeTook) - val endpoint = Vec3( packetVector.xCoord + speedVectors.xCoord * time, packetVector.yCoord + speedVectors.yCoord * time, @@ -158,9 +154,7 @@ object BloodCamp : Module( val (_, started, firstSpawn) = entityDataMap[entity]?.takeUnless { entity.isDead } ?: return@forEach val (currVector, endVector, endVecUpdated, speedVectors) = renderData - val endVectorUpdated = min(currentTickTime - endVecUpdated, 100) - - val endPoint = calcEndVector(endVector, renderData.lastEndVector, endVectorUpdated / 100f) + val endPoint = calcEndVector(endVector, renderData.lastEndVector, min(currentTickTime - endVecUpdated, 100) / 100f) val pingPoint = Vec3( entity.posX + speedVectors.xCoord * averagePing, @@ -199,13 +193,14 @@ object BloodCamp : Module( private fun getTime(firstSpawn: Boolean, timeTook: Long) = (if (firstSpawn) 2000 else 0) + (tick * 50) - timeTook + offset private fun calcEndVector(currVector: Vec3, lastVector: Vec3?, multiplier: Float, skip: Boolean = false): Vec3 { - return if (lastVector != null && !skip) { + return if (lastVector == null || skip) currVector + else { Vec3( lastVector.xCoord + (currVector.xCoord - lastVector.xCoord) * multiplier, lastVector.yCoord + (currVector.yCoord - lastVector.yCoord) * multiplier, lastVector.zCoord + (currVector.zCoord - lastVector.zCoord) * multiplier ) - } else currVector + } } @SubscribeEvent diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/Mimic.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/Mimic.kt index dda1b5b5c..f2c8a8175 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/Mimic.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/Mimic.kt @@ -32,7 +32,7 @@ object Mimic : Module( private val color by ColorSetting("Color", Color.RED.withAlpha(0.5f), allowAlpha = true, description = "The color of the box.").withDependency { mimicBox } private val lineWidth by NumberSetting("Line Width", 2f, 0.1f, 10f, 0.1f, description = "The width of the box's lines.").withDependency { mimicBox } - private const val MIMIC_TEXTURE ="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTE5YzEyNTQzYmM3NzkyNjA1ZWY2OGUxZjg3NDlhZThmMmEzODFkOTA4NWQ0ZDRiNzgwYmExMjgyZDM1OTdhMCJ9fX0K" + private const val MIMIC_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTE5YzEyNTQzYmM3NzkyNjA1ZWY2OGUxZjg3NDlhZThmMmEzODFkOTA4NWQ0ZDRiNzgwYmExMjgyZDM1OTdhMCJ9fX0K" @SubscribeEvent fun onEntityLeaveWorld(event: EntityLeaveWorldEvent) { diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/TerracottaTimer.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/TerracottaTimer.kt index 42bd76c09..13848a351 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/TerracottaTimer.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/TerracottaTimer.kt @@ -24,8 +24,8 @@ object TerracottaTimer : Module( @SubscribeEvent fun onBlockPacket(event: BlockChangeEvent) { - if (!DungeonUtils.isFloor(6) || !DungeonUtils.inBoss || !event.update.block.isFlowerPot || terracottaSpawning.any { it.pos.equal(event.pos.toVec3().addVec(0.5, 1.5, 0.5)) }) return - terracottaSpawning.add(Terracotta(event.pos.toVec3().addVec(0.5, 1.5, 0.5), if (DungeonUtils.floor.isMM) 12.0 else 15.0)) + if (DungeonUtils.isFloor(6) && DungeonUtils.inBoss && event.update.block.isFlowerPot && !terracottaSpawning.any { it.pos.equal(event.pos.toVec3().addVec(0.5, 1.5, 0.5)) }) + terracottaSpawning.add(Terracotta(event.pos.toVec3().addVec(0.5, 1.5, 0.5), if (DungeonUtils.floor.isMM) 12.0 else 15.0)) } @SubscribeEvent 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 1bdc64e26..925279fc6 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 @@ -5,7 +5,6 @@ import com.google.gson.reflect.TypeToken import me.odinmain.OdinMain.logger import me.odinmain.events.impl.BlockChangeEvent import me.odinmain.events.impl.RoomEnterEvent -import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.beamsAlpha import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.onPuzzleComplete import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha import me.odinmain.utils.addVec @@ -55,16 +54,16 @@ object BeamsSolver { } } - fun onRenderWorld() { + fun onRenderWorld(beamStyle: Int, beamsTracer: Boolean, beamsAlpha: Float) { if (DungeonUtils.currentRoomName != "Creeper Beams" || currentLanternPairs.isEmpty()) return currentLanternPairs.entries.forEach { positions -> val color = positions.value.second - Renderer.drawStyledBox(positions.key.toAABB(), color, depth = true, style = PuzzleSolvers.beamStyle) - Renderer.drawStyledBox(positions.value.first.toAABB(), color, depth = true, style = PuzzleSolvers.beamStyle) + Renderer.drawStyledBlock(positions.key, color, depth = true, style = beamStyle) + Renderer.drawStyledBlock(positions.value.first, color, depth = true, style = beamStyle) - if (PuzzleSolvers.beamsTracer) + if (beamsTracer) Renderer.draw3DLine(listOf(positions.key.toVec3().addVec(0.5, 0.5, 0.5), positions.value.first.toVec3().addVec(0.5, 0.5, 0.5)), color = color.withAlpha(beamsAlpha), depth = false, lineWidth = 2f) } } 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 f248c9f47..473b18370 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 @@ -1,10 +1,9 @@ package me.odinmain.features.impl.dungeon.puzzlesolvers import me.odinmain.OdinMain.mc -import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.blazeHeight -import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.blazeWidth import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.onPuzzleComplete import me.odinmain.utils.* +import me.odinmain.utils.render.Color import me.odinmain.utils.render.RenderUtils.renderBoundingBox import me.odinmain.utils.render.RenderUtils.renderVec import me.odinmain.utils.render.Renderer @@ -35,33 +34,29 @@ object BlazeSolver { else blazes.sortBy { hpMap[it] } } - fun onRenderWorld() { + fun onRenderWorld(blazeLineNext: Boolean, blazeLineAmount: Int, blazeStyle: Int, blazeFirstColor: Color, blazeSecondColor: Color, blazeAllColor: Color, blazeWidth: Float, blazeHeight: Float, blazeSendComplete: Boolean) { if (!DungeonUtils.currentRoomName.equalsOneOf("Lower Blaze", "Higher Blaze")) return if (blazes.isEmpty()) return - blazes.removeAll { - mc.theWorld?.getEntityByID(it.entityId) == null - } + blazes.removeAll { mc.theWorld?.getEntityByID(it.entityId) == null } if (blazes.isEmpty() && lastBlazeCount == 1) { LocationUtils.currentDungeon?.puzzles?.find { it.name == Puzzle.Blaze.name }?.status = PuzzleStatus.Completed - if (PuzzleSolvers.blazeSendComplete) partyMessage("Blaze puzzle solved!") - onPuzzleComplete("Higher Blaze") - onPuzzleComplete("Lower Blaze") + if (blazeSendComplete) partyMessage("Blaze puzzle solved!") + onPuzzleComplete(if (DungeonUtils.currentRoomName == "Higher Blaze") "Higher Blaze" else "Lower Blaze") lastBlazeCount = 0 return } lastBlazeCount = blazes.size blazes.forEachIndexed { index, entity -> val color = when (index) { - 0 -> PuzzleSolvers.blazeFirstColor - 1 -> PuzzleSolvers.blazeSecondColor - else -> PuzzleSolvers.blazeAllColor + 0 -> blazeFirstColor + 1 -> blazeSecondColor + else -> blazeAllColor } - val aabb = AxisAlignedBB(-blazeWidth / 2, -1 - (blazeHeight / 2), -blazeWidth / 2, blazeWidth / 2, (blazeHeight / 2) - 1, blazeWidth / 2).offset(entity.positionVector) + val aabb = AxisAlignedBB(-blazeWidth / 2.0, -1 - (blazeHeight / 2.0), -blazeWidth / 2.0, blazeWidth / 2.0, (blazeHeight / 2.0) - 1, blazeWidth / 2.0).offset(entity.positionVector) - Renderer.drawBox(aabb, color, - outlineAlpha = if (PuzzleSolvers.blazeStyle == 0) 0 else color.alpha, fillAlpha = if (PuzzleSolvers.blazeStyle == 1) 0 else color.alpha, depth = true) + Renderer.drawStyledBox(aabb, color, blazeStyle, depth = true) - if (PuzzleSolvers.blazeLineNext && index > 0 && index <= PuzzleSolvers.blazeLineAmount) + if (blazeLineNext && index > 0 && index <= blazeLineAmount) Renderer.draw3DLine(listOf(blazes[index - 1].renderVec, entity.renderBoundingBox.middle), color = color, lineWidth = 1f, depth = true) } } 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 05b25a4b5..759df1f83 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 @@ -6,6 +6,7 @@ import me.odinmain.events.impl.RoomEnterEvent import me.odinmain.utils.addRotationCoords import me.odinmain.utils.equalsOneOf import me.odinmain.utils.removeFirstOrNull +import me.odinmain.utils.render.Color import me.odinmain.utils.render.Renderer import me.odinmain.utils.skyblock.dungeon.DungeonUtils import me.odinmain.utils.skyblock.getBlockIdAt @@ -39,23 +40,22 @@ object BoulderSolver { var str = "" for (z in -3..2) { for (x in -3..3) { - roomComponent.vec3.addRotationCoords(room.rotation, x * 3, z * 3).let { str += if (getBlockIdAt(it.xCoord, 66.0, it.zCoord) == 0) "0" else "1" } + roomComponent.blockPos.addRotationCoords(room.rotation, x * 3, z * 3).let { str += if (getBlockIdAt(it.down(4)) == 0) "0" else "1" } } } currentPositions = solutions[str]?.map { sol -> - 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) } + val render = roomComponent.blockPos.addRotationCoords(room.rotation, sol[0], sol[1]).down(5) + val click = roomComponent.blockPos.addRotationCoords(room.rotation, sol[2], sol[3]).down(5) BoxPosition(render, click) }?.toMutableList() ?: return } - fun onRenderWorld() { + fun onRenderWorld(showAllBoulderClicks: Boolean, boulderStyle: Int, boulderColor: Color, boulderLineWidth: Float) { if (DungeonUtils.currentRoomName != "Boulder" || currentPositions.isEmpty()) return - if (PuzzleSolvers.showAllBoulderClicks) currentPositions.forEach { - Renderer.drawStyledBlock(it.render, PuzzleSolvers.boulderColor, PuzzleSolvers.boulderStyle, PuzzleSolvers.boulderLineWidth) - } - else currentPositions.firstOrNull()?.let { - Renderer.drawStyledBlock(it.render, PuzzleSolvers.boulderColor, PuzzleSolvers.boulderStyle, PuzzleSolvers.boulderLineWidth) + if (showAllBoulderClicks) currentPositions.forEach { + Renderer.drawStyledBlock(it.render, boulderColor, boulderStyle, boulderLineWidth) + } else currentPositions.firstOrNull()?.let { + Renderer.drawStyledBlock(it.render, boulderColor, boulderStyle, boulderLineWidth) } } 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 1e9cbccd3..0a91b603a 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 @@ -47,13 +47,13 @@ object IceFillSolver { Renderer.draw3DLine(currentPatterns, color = color, depth = true) } - fun onRoomEnter(event: RoomEnterEvent) = with (event.room) { + fun onRoomEnter(event: RoomEnterEvent, optimizePatterns: Boolean) = with (event.room) { if (this?.data?.name != "Ice Fill" || currentPatterns.isNotEmpty()) return - scanAllFloors(getRealCoords(15, 70, 7).toVec3(), rotation) + scanAllFloors(getRealCoords(15, 70, 7).toVec3(), rotation, optimizePatterns) } - private fun scanAllFloors(pos: Vec3, rotation: Rotations) { + private fun scanAllFloors(pos: Vec3, rotation: Rotations, optimizePatterns: Boolean) { listOf(pos, pos.add(transformTo(Vec3i(5, 1, 0), rotation)), pos.add(transformTo(Vec3i(12, 2, 0), rotation))).forEachIndexed { floorIndex, startPosition -> val floorHeight = representativeFloors[floorIndex] val startTime = System.nanoTime() @@ -65,7 +65,7 @@ object IceFillSolver { ) { modMessage("Section $floorIndex scan took ${(System.nanoTime() - startTime) / 1000000.0}ms pattern: $patternIndex") - (if (PuzzleSolvers.useOptimizedPatterns) IceFillFloors.advanced[floorIndex][patternIndex] else IceFillFloors.IceFillFloors[floorIndex][patternIndex]).toMutableList().let { + (if (optimizePatterns) IceFillFloors.advanced[floorIndex][patternIndex] else IceFillFloors.IceFillFloors[floorIndex][patternIndex]).toMutableList().let { currentPatterns.addAll(it.map { startPosition.addVec(x = 0.5, y = 0.1, z = 0.5).add(transformTo(it, rotation)) }) } return@forEachIndexed diff --git a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/PuzzleSolvers.kt b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/PuzzleSolvers.kt index eaa89e5f0..08d191523 100644 --- a/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/PuzzleSolvers.kt +++ b/src/main/kotlin/me/odinmain/features/impl/dungeon/puzzlesolvers/PuzzleSolvers.kt @@ -36,18 +36,18 @@ object PuzzleSolvers : Module( ) { private val waterDropDown by DropdownSetting("Water Board") private val waterSolver by BooleanSetting("Water Board Solver", false, description = "Shows you the solution to the water puzzle.").withDependency { waterDropDown } - val showTracer by BooleanSetting("Show Tracer", true, description = "Shows a tracer to the next lever.").withDependency { waterSolver && waterDropDown } - val tracerColorFirst by ColorSetting("Tracer Color First", Color.GREEN, true, description = "Color for the first tracer.").withDependency { showTracer && waterDropDown } - val tracerColorSecond by ColorSetting("Tracer Color Second", Color.ORANGE, true, description = "Color for the second tracer.").withDependency { showTracer && waterDropDown } - val reset by ActionSetting("Reset", description = "Resets the solver.") { + private val showTracer by BooleanSetting("Show Tracer", true, description = "Shows a tracer to the next lever.").withDependency { waterSolver && waterDropDown } + private val tracerColorFirst by ColorSetting("Tracer Color First", Color.GREEN, true, description = "Color for the first tracer.").withDependency { showTracer && waterDropDown } + private val tracerColorSecond by ColorSetting("Tracer Color Second", Color.ORANGE, true, description = "Color for the second tracer.").withDependency { showTracer && waterDropDown } + private val waterReset by ActionSetting("Reset", description = "Resets the solver.") { WaterSolver.reset() }.withDependency { waterSolver && waterDropDown } private val mazeDropDown by DropdownSetting("TP Maze") - private val tpMaze by BooleanSetting("Teleport Maze", false, description = "Shows you the solution for the TP maze puzzle.").withDependency { mazeDropDown } - val mazeColorOne by ColorSetting("Color for one", Color.GREEN.withAlpha(.5f), true, description = "Color for when there is a single solution.").withDependency { tpMaze && mazeDropDown } - val mazeColorMultiple by ColorSetting("Color for multiple", Color.ORANGE.withAlpha(.5f), true, description = "Color for when there are multiple solutions.").withDependency { tpMaze && mazeDropDown } - val mazeColorVisited by ColorSetting("Color for visited", Color.RED.withAlpha(.5f), true, description = "Color for the already used TP pads.").withDependency { tpMaze && mazeDropDown } + private val tpMaze by BooleanSetting("TP Maze Solver", false, description = "Shows you the solution for the TP maze puzzle.").withDependency { mazeDropDown } + private val mazeColorOne by ColorSetting("Color for one", Color.GREEN.withAlpha(.5f), true, description = "Color for when there is a single solution.").withDependency { tpMaze && mazeDropDown } + private val mazeColorMultiple by ColorSetting("Color for multiple", Color.ORANGE.withAlpha(.5f), true, description = "Color for when there are multiple solutions.").withDependency { tpMaze && mazeDropDown } + private val mazeColorVisited by ColorSetting("Color for visited", Color.RED.withAlpha(.5f), true, description = "Color for the already used TP pads.").withDependency { tpMaze && mazeDropDown } private val mazeReset by ActionSetting("Reset", description = "Resets the solver.") { TPMazeSolver.reset() }.withDependency { tpMaze && mazeDropDown } @@ -55,58 +55,58 @@ object PuzzleSolvers : Module( private val iceFillDropDown by DropdownSetting("Ice Fill") private val iceFillSolver by BooleanSetting("Ice Fill Solver", false, description = "Solver for the ice fill puzzle.").withDependency { iceFillDropDown } private val iceFillColor by ColorSetting("Ice Fill Color", Color.PINK, true, description = "Color for the ice fill solver.").withDependency { iceFillSolver && iceFillDropDown } - val useOptimizedPatterns by BooleanSetting("Use Optimized Patterns", false, description = "Use optimized patterns for the ice fill solver.").withDependency { iceFillSolver && iceFillDropDown } + private val useOptimizedPatterns by BooleanSetting("Use Optimized Patterns", false, description = "Use optimized patterns for the ice fill solver.").withDependency { iceFillSolver && iceFillDropDown } private val iceFillReset by ActionSetting("Reset", description = "Resets the solver.") { IceFillSolver.reset() }.withDependency { iceFillSolver && iceFillDropDown } private val blazeDropDown by DropdownSetting("Blaze") private val blazeSolver by BooleanSetting("Blaze Solver", description = "Shows you the solution for the Blaze puzzle").withDependency { blazeDropDown } - val blazeLineNext by BooleanSetting("Blaze Solver Next Line", true, description = "Shows the next line to click.").withDependency { blazeSolver && blazeDropDown } - val blazeLineAmount: Int by NumberSetting("Blaze Solver Lines", 1, 1, 10, 1, description = "Amount of lines to show.").withDependency { blazeSolver && blazeDropDown } - val blazeStyle by SelectorSetting("Blaze Style", "Outline", arrayListOf("Filled", "Outline", "Filled Outline"), description = "Whether or not the box should be filled.").withDependency { blazeSolver && blazeDropDown } - val blazeFirstColor by ColorSetting("First Color", Color.GREEN, true, description = "Color for the first blaze.").withDependency { blazeSolver && blazeDropDown } - val blazeSecondColor by ColorSetting("Second Color", Color.ORANGE, true, description = "Color for the second blaze.").withDependency { blazeSolver && blazeDropDown } - val blazeAllColor by ColorSetting("Other Color", Color.WHITE.withAlpha(.3f), true, description = "Color for the other blazes.").withDependency { blazeSolver && blazeDropDown } - val blazeWidth by NumberSetting("Box Width", 1.0, 0.5, 2.0, 0.1, description = "Width of the box.").withDependency { blazeSolver && blazeDropDown } - val blazeHeight by NumberSetting("Box Height", 2.0, 1.0, 3.0, 0.1, description = "Height of the box.").withDependency { blazeSolver && blazeDropDown } - val blazeSendComplete by BooleanSetting("Send Complete", false, description = "Send complete message.").withDependency { blazeSolver && blazeDropDown } + private val blazeLineNext by BooleanSetting("Blaze Solver Next Line", true, description = "Shows the next line to click.").withDependency { blazeSolver && blazeDropDown } + private val blazeLineAmount by NumberSetting("Blaze Solver Lines", 1, 1, 10, 1, description = "Amount of lines to show.").withDependency { blazeSolver && blazeDropDown } + private val blazeStyle by SelectorSetting("Blaze Style", "Outline", arrayListOf("Filled", "Outline", "Filled Outline"), description = "Whether or not the box should be filled.").withDependency { blazeSolver && blazeDropDown } + private val blazeFirstColor by ColorSetting("First Color", Color.GREEN, true, description = "Color for the first blaze.").withDependency { blazeSolver && blazeDropDown } + private val blazeSecondColor by ColorSetting("Second Color", Color.ORANGE, true, description = "Color for the second blaze.").withDependency { blazeSolver && blazeDropDown } + private val blazeAllColor by ColorSetting("Other Color", Color.WHITE.withAlpha(.3f), true, description = "Color for the other blazes.").withDependency { blazeSolver && blazeDropDown } + private val blazeWidth by NumberSetting("Box Width", 1f, 0.5, 2.0, 0.1, description = "Width of the box.").withDependency { blazeSolver && blazeDropDown } + private val blazeHeight by NumberSetting("Box Height", 2f, 1.0, 3.0, 0.1, description = "Height of the box.").withDependency { blazeSolver && blazeDropDown } + private val blazeSendComplete by BooleanSetting("Send Complete", false, description = "Send complete message.").withDependency { blazeSolver && blazeDropDown } private val blazeReset by ActionSetting("Reset", description = "Resets the solver.") { BlazeSolver.reset() }.withDependency { blazeSolver && blazeDropDown } private val beamsDropDown by DropdownSetting("Creeper Beams") private val beamsSolver by BooleanSetting("Creeper Beams Solver", false, description = "Shows you the solution for the Creeper Beams puzzle.").withDependency { beamsDropDown } - val beamStyle by SelectorSetting("Beam Style", "Filled Outline", arrayListOf("Filled", "Outline", "Filled Outline"), description = "Whether or not the box should be filled.").withDependency { beamsSolver && beamsDropDown } - val beamsTracer by BooleanSetting("Tracer", false, description = "Shows a tracer to the next lantern.").withDependency { beamsSolver && beamsDropDown } - val beamsAlpha by NumberSetting("Color Alpha", .7f, 0f, 1f, .05f, description = "The alpha of the color.").withDependency { beamsSolver && beamsDropDown } + private val beamStyle by SelectorSetting("Beams Style", "Filled Outline", arrayListOf("Filled", "Outline", "Filled Outline"), description = "Whether or not the box should be filled.").withDependency { beamsSolver && beamsDropDown } + private val beamsTracer by BooleanSetting("Beams Tracer", false, description = "Shows a tracer to the next lantern.").withDependency { beamsSolver && beamsDropDown } + private val beamsAlpha by NumberSetting("Beams Color Alpha", .7f, 0f, 1f, .05f, description = "The alpha of the color.").withDependency { beamsSolver && beamsDropDown } private val beamsReset by ActionSetting("Reset", description = "Resets the solver.") { BeamsSolver.reset() }.withDependency { beamsSolver && beamsDropDown } private val weirdosDropDown by DropdownSetting("Three Weirdos") private val weirdosSolver by BooleanSetting("Weirdos Solver", false, description = "Shows you the solution for the Weirdos puzzle.").withDependency { weirdosDropDown } - val weirdosColor by ColorSetting("Weirdos Color", Color.GREEN.withAlpha(0.7f), true, description = "Color for the weirdos solver.").withDependency { weirdosSolver && weirdosDropDown } - val weirdosWrongColor by ColorSetting("Weirdos Wrong Color", Color.RED.withAlpha(.7f), true, description = "Color for the incorrect Weirdos.").withDependency { weirdosSolver && weirdosDropDown } - val weirdosStyle by SelectorSetting("Weirdos Style", "Filled Outline", arrayListOf("Filled", "Outline", "Filled Outline"), description = "Whether or not the box should be filled.").withDependency { weirdosSolver && weirdosDropDown } + private val weirdosColor by ColorSetting("Weirdos Correct Color", Color.GREEN.withAlpha(0.7f), true, description = "Color for the weirdos solver.").withDependency { weirdosSolver && weirdosDropDown } + private val weirdosWrongColor by ColorSetting("Weirdos Wrong Color", Color.RED.withAlpha(.7f), true, description = "Color for the incorrect Weirdos.").withDependency { weirdosSolver && weirdosDropDown } + private val weirdosStyle by SelectorSetting("Weirdos Style", "Filled Outline", arrayListOf("Filled", "Outline", "Filled Outline"), description = "Whether or not the box should be filled.").withDependency { weirdosSolver && weirdosDropDown } private val weirdosReset by ActionSetting("Reset", description = "Resets the solver.") { WeirdosSolver.reset() }.withDependency { weirdosSolver && weirdosDropDown } private val quizDropdown by DropdownSetting("Quiz") private val quizSolver by BooleanSetting("Quiz Solver", false, description = "Solver for the trivia puzzle.").withDependency { quizDropdown } - val quizColor by ColorSetting("Quiz Color", Color.GREEN.withAlpha(.75f), true, description = "Color for the quiz solver.").withDependency { quizDropdown && quizSolver } - val quizDepth by BooleanSetting("Quiz Depth", false, description = "Depth check for the trivia puzzle.").withDependency { quizDropdown && quizSolver } + private val quizColor by ColorSetting("Quiz Color", Color.GREEN.withAlpha(.75f), true, description = "Color for the quiz solver.").withDependency { quizDropdown && quizSolver } + private val quizDepth by BooleanSetting("Quiz Depth", false, description = "Depth check for the trivia puzzle.").withDependency { quizDropdown && quizSolver } private val quizReset by ActionSetting("Reset", description = "Resets the solver.") { QuizSolver.reset() }.withDependency { quizDropdown && quizSolver } private val boulderDropDown by DropdownSetting("Boulder") private val boulderSolver by BooleanSetting("Boulder Solver", false, description = "Solver for the boulder puzzle.").withDependency { boulderDropDown } - val showAllBoulderClicks by BooleanSetting("Show All Boulder Clicks", true, description = "Shows all the clicks or only the first.").withDependency { boulderDropDown && boulderSolver } - val boulderStyle by SelectorSetting("Boulder Style", Renderer.DEFAULT_STYLE, Renderer.styles, description = Renderer.STYLE_DESCRIPTION).withDependency { boulderDropDown && boulderSolver } - val boulderColor by ColorSetting("Boulder Color", Color.GREEN.withAlpha(.5f), allowAlpha = true, description = "The color of the box.").withDependency { boulderDropDown && boulderSolver } - val boulderLineWidth by NumberSetting("Boulder Line Width", 2f, 0.1f, 10f, 0.1f, description = "The width of the box's lines.").withDependency { boulderDropDown && boulderSolver } + private val showAllBoulderClicks by BooleanSetting("Show All Boulder Clicks", true, description = "Shows all the clicks or only the first.").withDependency { boulderDropDown && boulderSolver } + private val boulderStyle by SelectorSetting("Boulder Style", Renderer.DEFAULT_STYLE, Renderer.styles, description = Renderer.STYLE_DESCRIPTION).withDependency { boulderDropDown && boulderSolver } + private val boulderColor by ColorSetting("Boulder Color", Color.GREEN.withAlpha(.5f), allowAlpha = true, description = "The color of the box.").withDependency { boulderDropDown && boulderSolver } + private val boulderLineWidth by NumberSetting("Boulder Line Width", 2f, 0.1f, 10f, 0.1f, description = "The width of the box's lines.").withDependency { boulderDropDown && boulderSolver } private val puzzleTimers by BooleanSetting("Puzzle Timers", true, description = "Shows the time it took to solve each puzzle.") private val sendPuzzleTime by BooleanSetting("Send Puzzle Time", false, description = "Sends the time it took to solve each puzzle in party chat.").withDependency { puzzleTimers } @@ -117,8 +117,8 @@ object PuzzleSolvers : Module( init { execute(500) { if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return@execute - if (waterSolver) WaterSolver.scan() if (blazeSolver) BlazeSolver.getBlaze() + if (waterSolver) WaterSolver.scan() } onPacket(S08PacketPlayerPosLook::class.java) { @@ -141,17 +141,17 @@ object PuzzleSolvers : Module( QuizSolver.onMessage(it) } - onPacket(S24PacketBlockAction::class.java) { - if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return@onPacket - if (it.blockType !is BlockChest) return@onPacket - val room = DungeonUtils.currentRoom?.takeIf { it.data.type == RoomType.PUZZLE } ?: return@onPacket + onPacket(S24PacketBlockAction::class.java) { packet -> + if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer) || packet.blockType !is BlockChest) return@onPacket + if (packet.blockType !is BlockChest) return@onPacket + val room = DungeonUtils.currentRoom?.takeIf { room -> room.data.type == RoomType.PUZZLE } ?: return@onPacket when (room.data.name) { - "Three Weirdos" -> it.blockPosition.equalsOneOf(room.getRealCoords(18, 69, 24), room.getRealCoords(16, 69, 25), room.getRealCoords(14, 69, 24)) - "Ice Fill" -> it.blockPosition.equalsOneOf(room.getRealCoords(14, 75, 29), room.getRealCoords(16, 75, 29)) - "Teleport Maze" -> it.blockPosition == room.getRealCoords(15, 70, 20) - "Water Board" -> it.blockPosition == room.getRealCoords(15, 56, 22) - "Boulder" -> it.blockPosition == room.getRealCoords(15, 66, 29) + "Three Weirdos" -> packet.blockPosition.equalsOneOf(room.getRealCoords(18, 69, 24), room.getRealCoords(16, 69, 25), room.getRealCoords(14, 69, 24)) + "Ice Fill" -> packet.blockPosition.equalsOneOf(room.getRealCoords(14, 75, 29), room.getRealCoords(16, 75, 29)) + "Teleport Maze" -> packet.blockPosition == room.getRealCoords(15, 70, 20) + "Water Board" -> packet.blockPosition == room.getRealCoords(15, 56, 22) + "Boulder" -> packet.blockPosition == room.getRealCoords(15, 66, 29) else -> false }.takeIf { !it } ?: onPuzzleComplete(room.data.name) } @@ -174,14 +174,14 @@ object PuzzleSolvers : Module( fun onWorldRender(event: RenderWorldLastEvent) { if ((!inDungeons || inBoss) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return profile("Puzzle Solvers Render") { - if (waterSolver) WaterSolver.onRenderWorld() - if (tpMaze) TPMazeSolver.onRenderWorld() if (iceFillSolver) IceFillSolver.onRenderWorld(iceFillColor) - if (blazeSolver) BlazeSolver.onRenderWorld() - if (beamsSolver) BeamsSolver.onRenderWorld() - if (weirdosSolver) WeirdosSolver.onRenderWorld() - if (quizSolver) QuizSolver.onRenderWorld() - if (boulderSolver) BoulderSolver.onRenderWorld() + if (weirdosSolver) WeirdosSolver.onRenderWorld(weirdosColor, weirdosWrongColor, weirdosStyle) + if (boulderSolver) BoulderSolver.onRenderWorld(showAllBoulderClicks, boulderStyle, boulderColor, boulderLineWidth) + if (blazeSolver) BlazeSolver.onRenderWorld(blazeLineNext, blazeLineAmount, blazeStyle, blazeFirstColor, blazeSecondColor, blazeAllColor, blazeWidth, blazeHeight, blazeSendComplete) + if (beamsSolver) BeamsSolver.onRenderWorld(beamStyle, beamsTracer, beamsAlpha) + if (waterSolver) WaterSolver.onRenderWorld(showTracer, tracerColorFirst, tracerColorSecond) + if (quizSolver) QuizSolver.onRenderWorld(quizColor, quizDepth) + if (tpMaze) TPMazeSolver.onRenderWorld(mazeColorOne, mazeColorMultiple, mazeColorVisited) } } @@ -189,11 +189,11 @@ object PuzzleSolvers : Module( @SubscribeEvent fun onRoomEnter(event: RoomEnterEvent) { - IceFillSolver.onRoomEnter(event) - BeamsSolver.onRoomEnter(event) - QuizSolver.onRoomEnter(event) BoulderSolver.onRoomEnter(event) + IceFillSolver.onRoomEnter(event, useOptimizedPatterns) TPMazeSolver.onRoomEnter(event) + BeamsSolver.onRoomEnter(event) + QuizSolver.onRoomEnter(event) if (puzzleTimers && event.room?.data?.type == RoomType.PUZZLE && puzzleTimersMap.none { it.key == event.room.data.name }) puzzleTimersMap[event.room.data.name] = PuzzleTimer() } 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 b1757c479..0c00698b9 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 @@ -5,9 +5,7 @@ import com.google.gson.reflect.TypeToken import me.odinmain.OdinMain.logger import me.odinmain.events.impl.RoomEnterEvent import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.onPuzzleComplete -import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.quizDepth -import me.odinmain.utils.render.RenderUtils -import me.odinmain.utils.render.Renderer +import me.odinmain.utils.render.* import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords import me.odinmain.utils.startsWithOneOf import me.odinmain.utils.toAABB @@ -68,13 +66,13 @@ object QuizSolver { triviaOptions[2].blockPos = getRealCoords(BlockPos(10.0, 70.0, 6.0)) } - fun onRenderWorld() { + fun onRenderWorld(quizColor: Color, quizDepth: Boolean) { if (triviaAnswers == null || triviaOptions.isEmpty()) return triviaOptions.forEach { answer -> if (!answer.isCorrect) return@forEach answer.blockPos?.add(0.0, -1.0, 0.0)?.let { - Renderer.drawBox(it.toAABB(), PuzzleSolvers.quizColor, depth = quizDepth) - RenderUtils.drawBeaconBeam(it.toVec3(), PuzzleSolvers.quizColor, depth = quizDepth) + Renderer.drawBlock(it, quizColor, depth = quizDepth) + RenderUtils.drawBeaconBeam(it.toVec3(), 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 fb2f0d984..a12dc8e6a 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 @@ -2,9 +2,6 @@ package me.odinmain.features.impl.dungeon.puzzlesolvers import me.odinmain.OdinMain.mc import me.odinmain.events.impl.RoomEnterEvent -import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.mazeColorMultiple -import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.mazeColorOne -import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.mazeColorVisited import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha import me.odinmain.utils.* import me.odinmain.utils.render.Color @@ -42,7 +39,7 @@ object TPMazeSolver { } } - fun onRenderWorld() { + fun onRenderWorld(mazeColorOne: Color, mazeColorMultiple: Color, mazeColorVisited: Color) { if (DungeonUtils.currentRoomName != "Teleport Maze") return tpPads.forEach { when (it) { 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 896276c38..271e72791 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 @@ -65,22 +65,24 @@ object WaterSolver { } } - fun onRenderWorld() { + fun onRenderWorld(showTracer: Boolean, tracerColorFirst: Color, tracerColorSecond: Color) { if (patternIdentifier == -1 || solutions.isEmpty() || DungeonUtils.currentRoomName != "Water Board") return val solutionList = solutions .flatMap { (lever, times) -> times.drop(lever.i).map { Pair(lever, it) } } .sortedBy { (lever, time) -> time + if (lever == LeverBlock.WATER) 0.01 else 0.0 } - val firstSolution = solutionList.firstOrNull() ?: return - if (PuzzleSolvers.showTracer) Renderer.drawTracer(firstSolution.first.leverPos.addVector(.5, .5, .5), color = PuzzleSolvers.tracerColorFirst, depth = true) + if (showTracer) { + val firstSolution = solutionList.firstOrNull()?.first ?: return + Renderer.drawTracer(firstSolution.leverPos.addVector(.5, .5, .5), color = tracerColorFirst, depth = true) - if (solutionList.size > 1 && PuzzleSolvers.showTracer && firstSolution.first.leverPos != solutionList[1].first.leverPos) { - Renderer.draw3DLine( - listOf(firstSolution.first.leverPos.addVector(.5, .5, .5), solutionList[1].first.leverPos.addVector(.5, .5, .5)), - color = PuzzleSolvers.tracerColorSecond, lineWidth = 1.5f, depth = true - ) + if (solutionList.size > 1 && firstSolution.leverPos != solutionList[1].first.leverPos) { + Renderer.draw3DLine( + listOf(firstSolution.leverPos.addVector(.5, .5, .5), solutionList[1].first.leverPos.addVector(.5, .5, .5)), + color = tracerColorSecond, lineWidth = 1.5f, depth = true + ) + } } solutions.forEach { (lever, times) -> 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 ef7c42e4b..eb419322a 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 @@ -2,22 +2,24 @@ package me.odinmain.features.impl.dungeon.puzzlesolvers import me.odinmain.OdinMain.mc import me.odinmain.utils.* +import me.odinmain.utils.render.Color import me.odinmain.utils.render.Renderer import me.odinmain.utils.skyblock.PlayerUtils import me.odinmain.utils.skyblock.dungeon.DungeonUtils import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.util.BlockPos import net.minecraft.util.Vec3 import java.util.concurrent.CopyOnWriteArraySet object WeirdosSolver { - private var correctPos: Vec3? = null - private var wrongPositions = CopyOnWriteArraySet() + private var correctPos: BlockPos? = null + private var wrongPositions = CopyOnWriteArraySet() 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.currentRoom ?: return - val pos = Vec3(correctNPC.posX - 0.5, 69.0, correctNPC.posZ - 0.5).addRotationCoords(room.rotation, -1, 0) + val pos = BlockPos(correctNPC.posX - 0.5, 69.0, correctNPC.posZ - 0.5).addRotationCoords(room.rotation, -1, 0) if (solutions.any { it.matches(msg) }) { correctPos = pos @@ -25,15 +27,11 @@ object WeirdosSolver { } else wrongPositions.add(pos) } - fun onRenderWorld() { + fun onRenderWorld(weirdosColor: Color, weirdosWrongColor: Color, weirdosStyle: Int) { if (DungeonUtils.currentRoomName != "Three Weirdos") return - correctPos?.let { - Renderer.drawBox(it.toAABB(), PuzzleSolvers.weirdosColor, outlineAlpha = if (PuzzleSolvers.weirdosStyle == 0) 0 else PuzzleSolvers.weirdosColor.alpha, - fillAlpha = if (PuzzleSolvers.weirdosStyle == 1) 0 else PuzzleSolvers.weirdosColor.alpha) - } + correctPos?.let { Renderer.drawStyledBlock(it, weirdosColor, weirdosStyle) } wrongPositions.forEach { - Renderer.drawBox(it.toAABB(), PuzzleSolvers.weirdosWrongColor, outlineAlpha = if (PuzzleSolvers.weirdosStyle == 0) 0 else PuzzleSolvers.weirdosWrongColor.alpha, - fillAlpha = if (PuzzleSolvers.weirdosStyle == 1) 0 else PuzzleSolvers.weirdosWrongColor.alpha) + Renderer.drawStyledBlock(it, weirdosWrongColor, weirdosStyle) } } diff --git a/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragonEnum.kt b/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragonEnum.kt index 12e96e13d..1c55925a4 100644 --- a/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragonEnum.kt +++ b/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragonEnum.kt @@ -48,7 +48,7 @@ enum class WitherDragonsEnum ( Purple(Vec3(56.0, 14.0, 125.0), AxisAlignedBB(45.5, 13.0, 113.5,68.5, 23.0, 136.5), '5', Color.PURPLE,53.0..59.0, 122.0..128.0, skipKillTime = 38), - None( Vec3(0.0, 0.0, 0.0), AxisAlignedBB(0.0, 0.0, 0.0, 0.0, 0.0, 0.0), 'f', Color.WHITE, 0.0..0.0, 0.0..0.0); + None( Vec3(0.0, 0.0, 0.0), AxisAlignedBB(0.0, 0.0, 0.0, 0.0, 0.0, 0.0), 'f', Color.WHITE, 0.0..0.0, 0.0..0.0); fun setAlive(entityId: Int) { state = WitherDragonState.ALIVE diff --git a/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragons.kt b/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragons.kt index cd9fcc751..5a6141c7a 100644 --- a/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragons.kt +++ b/src/main/kotlin/me/odinmain/features/impl/floor7/WitherDragons.kt @@ -33,31 +33,26 @@ object WitherDragons : Module( ) { private val dragonTimerDropDown by DropdownSetting("Dragon Timer Dropdown") private val dragonTimer by BooleanSetting("Dragon Timer", true, description = "Displays a timer for when M7 dragons spawn.").withDependency { dragonTimerDropDown } - val addUselessDecimal by BooleanSetting("Add Useless Decimal", false, description = "Adds a decimal to the timer.").withDependency { dragonTimer && dragonTimerDropDown } private val hud by HudSetting("Dragon Timer HUD", 10f, 10f, 1f, true) { if (it) { mcText("§5P §a4.5s", 2f, 5f, 1, Color.WHITE, center = false) - mcText("§cR §e1.2s", 2f, 20f, 1, Color.WHITE, center = false) - getMCTextWidth("§5P §a4.5s")+ 2f to 33f } else { - if (!dragonTimer) return@HudSetting 0f to 0f - WitherDragonsEnum.entries.forEachIndexed { index, dragon -> - if (dragon.state != WitherDragonState.SPAWNING) return@forEachIndexed - mcText("§${dragon.colorCode}${dragon.name.first()}: ${colorDragonTimer(dragon.timeToSpawn)}${String.format(Locale.US, "%.2f", dragon.timeToSpawn / 20.0)}${if (addUselessDecimal) "0" else ""}", 2, 5f + (index - 1) * 15f, 1, Color.WHITE, center = false) + priorityDragon.takeIf { drag -> drag != WitherDragonsEnum.None }?.let { dragon -> + mcText("§${dragon.colorCode}${dragon.name.first()}: ${colorDragonTimer(dragon.timeToSpawn)}${String.format(Locale.US, "%.2f", dragon.timeToSpawn / 20.0)}", 2, 5f, 1, Color.WHITE, center = false) } getMCTextWidth("§5P §a4.5s")+ 2f to 33f } - }.withDependency { dragonTimer && dragonTimerDropDown } + }.withDependency { dragonTimerDropDown } private val dragonBoxesDropDown by DropdownSetting("Dragon Boxes Dropdown") private val dragonBoxes by BooleanSetting("Dragon Boxes", true, description = "Displays boxes for where M7 dragons spawn.").withDependency { dragonBoxesDropDown } - val lineThickness by NumberSetting("Line Width", 2f, 1.0, 5.0, 0.5, description = "The thickness of the lines for the boxes.").withDependency { dragonBoxes && dragonBoxesDropDown } + private val lineThickness by NumberSetting("Line Width", 2f, 1.0, 5.0, 0.5, description = "The thickness of the lines for the boxes.").withDependency { dragonBoxes && dragonBoxesDropDown } private val dragonTitleDropDown by DropdownSetting("Dragon Spawn Dropdown") val dragonTitle by BooleanSetting("Dragon Title", true, description = "Displays a title for spawning dragons.").withDependency { dragonTitleDropDown } private val dragonTracers by BooleanSetting("Dragon Tracer", false, description = "Draws a line to spawning dragons.").withDependency { dragonTitleDropDown } - val tracerThickness by NumberSetting("Tracer Width", 5f, 1f, 20f, 0.5, description = "The thickness of the tracers.").withDependency { dragonTracers && dragonTitleDropDown } + private val tracerThickness by NumberSetting("Tracer Width", 5f, 1f, 20f, 0.5, description = "The thickness of the tracers.").withDependency { dragonTracers && dragonTitleDropDown } private val dragonAlerts by DropdownSetting("Dragon Alerts Dropdown") val sendNotification by BooleanSetting("Send Dragon Confirmation", true, description = "Sends a confirmation message when a dragon dies.").withDependency { dragonAlerts } @@ -84,7 +79,7 @@ object WitherDragons : Module( val selected by SelectorSetting("Color", "Green", colors, description = "The color of your relic.").withDependency { relicAnnounce && relicDropDown} val relicAnnounceTime by BooleanSetting("Relic Time", true, description = "Sends how long it took you to get that relic.").withDependency { relicDropDown } val relicSpawnTicks by NumberSetting("Relic Spawn Ticks", 42, 0, 100, description = "The amount of ticks for the relic to spawn.").withDependency { relicDropDown } - val cauldronHighlight by BooleanSetting("Cauldron Highlight", true, description = "Highlights the cauldron for held relic.").withDependency { relicDropDown } + private val cauldronHighlight by BooleanSetting("Cauldron Highlight", true, description = "Highlights the cauldron for held relic.").withDependency { relicDropDown } private val relicHud by HudSetting("Relic Hud", 10f, 10f, 1f, true) { if (it) return@HudSetting mcTextAndWidth("§3Relics: 4.30s", 2, 5f, 1, Color.WHITE, center = false) + 2f to 16f @@ -148,7 +143,7 @@ object WitherDragons : Module( if (dragonTimer) { WitherDragonsEnum.entries.forEach { dragon -> if (dragon.state == WitherDragonState.SPAWNING) Renderer.drawStringInWorld( - "§${dragon.colorCode}${dragon.name.first()}: ${colorDragonTimer(dragon.timeToSpawn)}${String.format(Locale.US, "%.2f", dragon.timeToSpawn / 20.0)}${if (addUselessDecimal) "0" else ""}", dragon.spawnPos, + "§${dragon.colorCode}${dragon.name.first()}: ${colorDragonTimer(dragon.timeToSpawn)}${String.format(Locale.US, "%.2f", dragon.timeToSpawn / 20.0)}", dragon.spawnPos, color = Color.WHITE, depth = false, scale = 0.16f ) } @@ -161,7 +156,6 @@ object WitherDragons : Module( if (cauldronHighlight) relicsOnWorldLast() if (priorityDragon != WitherDragonsEnum.None && dragonTracers && priorityDragon.state == WitherDragonState.SPAWNING) Renderer.drawTracer(priorityDragon.spawnPos.addVec(0.5, 3.5, 0.5), color = priorityDragon.color, lineWidth = tracerThickness) - } @SubscribeEvent diff --git a/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt b/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt index 1da52c4d0..f5642123e 100644 --- a/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt +++ b/src/main/kotlin/me/odinmain/features/impl/floor7/p3/TerminalSolver.kt @@ -48,7 +48,7 @@ object TerminalSolver : Module( private val lockRubixSolution by BooleanSetting("Lock Rubix Solution", true, description = "Locks the 'correct' color of the rubix terminal to the one that was scanned first, should make the solver less 'jumpy'.") private val cancelToolTip by BooleanSetting("Stop Tooltips", true, description = "Stops rendering tooltips in terminals.").withDependency { renderType != 3 } private val blockIncorrectClicks by BooleanSetting("Block Incorrect Clicks", true, description = "Blocks incorrect clicks in terminals.").withDependency { renderType != 3 } - private val middleClickGUI by BooleanSetting("Middle Click GUI", true, description = "Opens the custom gui when middle clicking in the terminal.").withDependency { renderType != 3 } + private val middleClickGUI by BooleanSetting("Middle Click GUI", true, description = "Replaces right click with middle click in terminals.").withDependency { renderType != 3 } private val cancelMelodySolver by BooleanSetting("Stop Melody Solver", false, description = "Stops rendering the melody solver.") private val showRemoveWrongSettings by DropdownSetting("Render Wrong Settings").withDependency { renderType == 1 } diff --git a/src/main/kotlin/me/odinmain/features/impl/nether/BlazeAttunement.kt b/src/main/kotlin/me/odinmain/features/impl/nether/BlazeAttunement.kt index ecb75b50d..da7d291b0 100644 --- a/src/main/kotlin/me/odinmain/features/impl/nether/BlazeAttunement.kt +++ b/src/main/kotlin/me/odinmain/features/impl/nether/BlazeAttunement.kt @@ -46,7 +46,7 @@ object BlazeAttunement : Module( val entities = mc.theWorld?.getEntitiesWithinAABBExcludingEntity(entity, entity.entityBoundingBox.offset(0.0, -1.0, 0.0)) ?.filter { it is EntityBlaze || it is EntitySkeleton || it is EntityPigZombie } - ?.sortedByDescending { xzDistance(it, entity) } + ?.sortedByDescending { it.xzDistance(entity) } ?.takeIf { it.isNotEmpty() } ?: return@execute currentBlazes[entities.first()] = color } @@ -55,8 +55,7 @@ object BlazeAttunement : Module( @SubscribeEvent fun onRenderEntityModel(event: RenderEntityModelEvent) { - val color = currentBlazes[event.entity] ?: return - OutlineUtils.outlineEntity(event, color, thickness) + OutlineUtils.outlineEntity(event, currentBlazes[event.entity] ?: return, thickness) } @JvmStatic diff --git a/src/main/kotlin/me/odinmain/features/impl/nether/KuudraReminders.kt b/src/main/kotlin/me/odinmain/features/impl/nether/KuudraReminders.kt index 32ff38cac..d39730d37 100644 --- a/src/main/kotlin/me/odinmain/features/impl/nether/KuudraReminders.kt +++ b/src/main/kotlin/me/odinmain/features/impl/nether/KuudraReminders.kt @@ -28,10 +28,10 @@ object KuudraReminders : Module( private data class Reminder(val regex: Regex, val shouldRun: Boolean, val alert: String) private val reminders = listOf( Reminder(Regex("WARNING: You do not have a key for this tier in your inventory, you will not be able to claim rewards."), keyReminder, "No key in inventory"), - Reminder(Regex("\\[NPC] Elle: Okay adventurers, I will go and fish up Kuudra!"), buyUpgrades, "No key in inventory"), - Reminder(Regex("\\[NPC] Elle: Not again!"), pickUpSupplies, "No key in inventory"), + Reminder(Regex("Your Fresh Tools Perk bonus doubles your building speed for the next 10 seconds!"), freshTools, "No key in inventory"), Reminder(Regex("\\[NPC] Elle: It's time to build the Ballista again! Cover me!"), buildBallista, "No key in inventory"), - Reminder(Regex("Your Fresh Tools Perk bonus doubles your building speed for the next 10 seconds!"), freshTools, "No key in inventory") + Reminder(Regex("\\[NPC] Elle: Okay adventurers, I will go and fish up Kuudra!"), buyUpgrades, "No key in inventory"), + Reminder(Regex("\\[NPC] Elle: Not again!"), pickUpSupplies, "No key in inventory") ) init { @@ -44,7 +44,7 @@ object KuudraReminders : Module( onMessage(Regex("Used Extreme Focus! \\((\\d+) Mana\\)"), { enabled && manaDrain && (onlyKuudra && KuudraUtils.inKuudra)}) { val mana = Regex("Used Extreme Focus! \\((\\d+) Mana\\)").find(it)?.groupValues?.get(1)?.toIntOrNull() ?: return@onMessage val players = mc.theWorld?.playerEntities?.filter { entity -> entity.isOtherPlayer() && entity.getDistanceSqToEntity(mc.thePlayer) < 49 }?.takeIf { it.isNotEmpty() } ?: return@onMessage - partyMessage("Used $mana mana on ${players.joinToString(", ") { it.name }}.") + partyMessage("Used $mana mana on ${players.joinToString(", ") { player -> player.name }}.") } } } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/features/impl/nether/NoPre.kt b/src/main/kotlin/me/odinmain/features/impl/nether/NoPre.kt index f576b65a4..dc3726153 100644 --- a/src/main/kotlin/me/odinmain/features/impl/nether/NoPre.kt +++ b/src/main/kotlin/me/odinmain/features/impl/nether/NoPre.kt @@ -81,7 +81,7 @@ object NoPre : Module( } } - fun cratePriority(missing: SupplyPickUpSpot): String { + private fun cratePriority(missing: SupplyPickUpSpot): String { return when (missing) { // Shop Missing SupplyPickUpSpot.Shop -> when (preSpot) { diff --git a/src/main/kotlin/me/odinmain/features/impl/nether/VanqNotifier.kt b/src/main/kotlin/me/odinmain/features/impl/nether/VanqNotifier.kt index 196d13380..41e6ad78f 100644 --- a/src/main/kotlin/me/odinmain/features/impl/nether/VanqNotifier.kt +++ b/src/main/kotlin/me/odinmain/features/impl/nether/VanqNotifier.kt @@ -17,10 +17,10 @@ object VanqNotifier: Module( init { onMessage(Regex("A Vanquisher is spawning nearby!")) { - modMessage("Vanquisher has spawned!") PlayerUtils.alert("§5Vanquisher", playSound = playSound, displayText = showText) - if (ac) allMessage(PlayerUtils.getPositionString()) if (pc) partyMessage(PlayerUtils.getPositionString()) + if (ac) allMessage(PlayerUtils.getPositionString()) + modMessage("§2Vanquisher has spawned!") } } } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/features/impl/render/DevPlayers.kt b/src/main/kotlin/me/odinmain/features/impl/render/DevPlayers.kt index 53f84d8a6..d35920cc4 100644 --- a/src/main/kotlin/me/odinmain/features/impl/render/DevPlayers.kt +++ b/src/main/kotlin/me/odinmain/features/impl/render/DevPlayers.kt @@ -66,7 +66,6 @@ object DevPlayers { return s.replace(pattern) { match -> match.groupValues[1] } } - @OptIn(DelicateCoroutinesApi::class) fun updateDevs(): HashMap { runBlocking(scope.coroutineContext) { val data = convertDecimalToNumber(getDataFromServer("https://tj4yzotqjuanubvfcrfo7h5qlq0opcyk.lambda-url.eu-north-1.on.aws/")).ifEmpty { return@runBlocking } diff --git a/src/main/kotlin/me/odinmain/features/impl/render/Waypoints.kt b/src/main/kotlin/me/odinmain/features/impl/render/Waypoints.kt index af3913cef..40090802b 100644 --- a/src/main/kotlin/me/odinmain/features/impl/render/Waypoints.kt +++ b/src/main/kotlin/me/odinmain/features/impl/render/Waypoints.kt @@ -28,7 +28,7 @@ object Waypoints : Module( if (!pingLocationToggle) return@onPress EtherWarpHelper.getEtherPos(PositionLook(mc.thePlayer.renderVec, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch), pingDistance).pos?.let { pos -> val position = pos.addVec(0.5, 0.5, 0.5) - WaypointManager.addTempWaypoint(x = position.x.toInt(), y = position.y.toInt(), z = position.z.toInt(), time = pingWaypointTime) + WaypointManager.addTempWaypoint(x = position.x, y = position.y, z = position.z, time = pingWaypointTime) if (sendPingedLocation) sendCommand("odinwaypoint share ${position.x} ${position.y} ${position.z}", true) } }.withDependency { pingLocationToggle && pingLocationDropDown } diff --git a/src/main/kotlin/me/odinmain/features/impl/skyblock/ChatCommands.kt b/src/main/kotlin/me/odinmain/features/impl/skyblock/ChatCommands.kt index 61da53600..34a7c777a 100644 --- a/src/main/kotlin/me/odinmain/features/impl/skyblock/ChatCommands.kt +++ b/src/main/kotlin/me/odinmain/features/impl/skyblock/ChatCommands.kt @@ -61,19 +61,19 @@ object ChatCommands : Module( init { onMessage(Regex(" {29}> EXTRA STATS <|^\\[NPC] Elle: Good job everyone. A hard fought battle come to an end. Let's get out of here before we run into any more trouble!$")) { - if (dtReason.isEmpty() || !dt) return@onMessage + if (!dt || dtReason.isEmpty()) return@onMessage runIn(30) { - PlayerUtils.alert("§cPlayers need DT") partyMessage("Players need DT: ${dtReason.groupBy({ it.second }, { it.first }).entries.joinToString(separator = ", ") { (reason, names) -> "${names.joinToString(", ")}: $reason" }}") + PlayerUtils.alert("§cPlayers need DT") dtReason.clear() } } onMessage(messageRegex) { val channel = when(it.split(" ")[0]) { - "Party" -> if (!party) return@onMessage else ChatChannel.PARTY - "Guild" -> if (!guild) return@onMessage else ChatChannel.GUILD "From" -> if (!private) return@onMessage else ChatChannel.PRIVATE + "Party" -> if (!party) return@onMessage else ChatChannel.PARTY + "Guild" -> if (!guild) return@onMessage else ChatChannel.GUILD else -> return@onMessage } @@ -130,15 +130,15 @@ object ChatCommands : Module( "downtime", "dt" -> { if (!dt || channel != ChatChannel.PARTY) return val reason = message.substringAfter("dt ").takeIf { it != message && !it.contains("!dt") } ?: "No reason given" - if (dtReason.any { it.first == name }) return modMessage("§cThat player already has a reminder!") - dtReason.add(name to reason) + if (dtReason.any { it.first == name }) return modMessage("§6${name} §calready has a reminder!") modMessage("§aReminder set for the end of the run! §7(disabled auto requeue for this run)") - dtPlayer = name + dtReason.add(name to reason) disableRequeue = true + dtPlayer = name } "f1", "f2", "f3", "f4", "f5", "f6", "f7", "m1", "m2", "m3", "m4", "m5", "m6", "m7", "t1", "t2", "t3", "t4", "t5" -> { if (!queInstance || channel != ChatChannel.PARTY) return - modMessage("§aEntering -> ${message.substring(1).capitalizeFirst()}") + modMessage("§8Entering -> §e${message.substring(1).capitalizeFirst()}") sendCommand("od ${message.substring(1)}", true) } "demote" -> if (demote && channel == ChatChannel.PARTY) sendCommand("p demote $name") @@ -146,21 +146,17 @@ object ChatCommands : Module( // Private cmds only "invite", "inv" -> if (invite && channel == ChatChannel.PRIVATE) { + modMessage("§aClick on this message to invite $name to your party!", chatStyle = createClickStyle(ClickEvent.Action.RUN_COMMAND, "/party invite $name")) PlayerUtils.playLoudSound("note.pling", 100f, 1f) - modMessage("§aClick on this message to invite $name to your party!", - chatStyle = createClickStyle(ClickEvent.Action.RUN_COMMAND, "/party invite $name")) } } } - private var replaced = false - @SubscribeEvent fun onMessageSent(event: MessageSentEvent) { - if (!chatEmotes) return - if (event.message.startsWith("/") && !listOf("/pc", "/ac", "/gc", "/msg", "/w", "/r").any { event.message.startsWith(it) }) return + if (!chatEmotes ||( event.message.startsWith("/") && !listOf("/pc", "/ac", "/gc", "/msg", "/w", "/r").any { event.message.startsWith(it) })) return - replaced = false + var replaced = false val words = event.message.split(" ").toMutableList() for (i in words.indices) { @@ -170,11 +166,10 @@ object ChatCommands : Module( } } - val newMessage = words.joinToString(" ") if (!replaced) return event.isCanceled = true - sendChatMessage(newMessage) + sendChatMessage(words.joinToString(" ")) } private val replacements = mapOf( diff --git a/src/main/kotlin/me/odinmain/features/impl/skyblock/DianaHelper.kt b/src/main/kotlin/me/odinmain/features/impl/skyblock/DianaHelper.kt index 0dcdb1ccd..bb7fb252f 100644 --- a/src/main/kotlin/me/odinmain/features/impl/skyblock/DianaHelper.kt +++ b/src/main/kotlin/me/odinmain/features/impl/skyblock/DianaHelper.kt @@ -87,9 +87,8 @@ object DianaHelper : Module( if (sendInqMsg) partyMessage("${PlayerUtils.getPositionString()} I dug up an inquisitor come over here!") PlayerUtils.alert("§6§lInquisitor!") } - - onMessage(Regex(".*")) { - DianaBurrowEstimate.chat(it) + onMessage(Regex("^(You dug out a Griffin Burrow! .+|You finished the Griffin burrow chain! \\(4\\/4\\))\$")) { + DianaBurrowEstimate.onBurrowDug() } } diff --git a/src/main/kotlin/me/odinmain/features/impl/skyblock/PlayerDisplay.kt b/src/main/kotlin/me/odinmain/features/impl/skyblock/PlayerDisplay.kt index a8964800e..2d3bef345 100644 --- a/src/main/kotlin/me/odinmain/features/impl/skyblock/PlayerDisplay.kt +++ b/src/main/kotlin/me/odinmain/features/impl/skyblock/PlayerDisplay.kt @@ -38,8 +38,7 @@ object PlayerDisplay : Module( private val healthHud by HudSetting("Health Hud", 10f, 10f, 1f, true) { example -> val text = - if (example) - generateText(5000, 5000, "❤") + if (example) generateText(5000, 5000, "❤") else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f else if (SkyblockPlayer.currentHealth != 0 && SkyblockPlayer.maxHealth != 0) generateText(SkyblockPlayer.currentHealth, SkyblockPlayer.maxHealth, "❤") @@ -63,8 +62,7 @@ object PlayerDisplay : Module( private val manaColor by ColorSetting("Mana Color", Color.BLUE, true, description = "The color of the mana text.") private val overflowManaHud by HudSetting("Overflow Mana Hud", 10f, 10f, 1f, true) { example -> - val text = if (example) - generateText(333, "ʬ", hideZeroSF) + val text = if (example) generateText(333, "ʬ", hideZeroSF) else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f else if (separateOverflow) generateText(SkyblockPlayer.overflowMana, "ʬ", hideZeroSF) @@ -75,8 +73,7 @@ object PlayerDisplay : Module( private val overflowManaColor by ColorSetting("Overflow Mana Color", Color.CYAN, true, description = "The color of the overflow mana text.") private val defenseHud by HudSetting("Defense Hud", 10f, 10f, 1f, true) { example -> - val text = if (example) - generateText(1000, "❈", true) + val text = if (example) generateText(1000, "❈", true) else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f else if (SkyblockPlayer.currentDefense != 0) generateText(SkyblockPlayer.currentDefense, "❈", true) @@ -88,8 +85,7 @@ object PlayerDisplay : Module( private val defenseColor by ColorSetting("Defense Color", Color.GREEN, true, description = "The color of the defense text.") private val eHPHud by HudSetting("EffectiveHealth Hud", 10f, 10f, 1f, true) { example -> - val text = if (example) - generateText(1000000, "", true) + val text = if (example) generateText(1000000, "", true) else if(!LocationUtils.isInSkyblock) return@HudSetting 0f to 0f else if (SkyblockPlayer.effectiveHP != 0) generateText(SkyblockPlayer.effectiveHP, "", true) else return@HudSetting 0f to 0f @@ -114,7 +110,7 @@ object PlayerDisplay : Module( } private fun generateText(current: Int, icon: String, hideZero: Boolean): String{ - if(hideZero && current == 0) return "" + if (hideZero && current == 0) return "" return "${formatNumberWithCustomSeparator(current)}${if (showIcons) icon else ""}" } diff --git a/src/main/kotlin/me/odinmain/features/impl/skyblock/RagnarokAxe.kt b/src/main/kotlin/me/odinmain/features/impl/skyblock/RagnarokAxe.kt index c21568b73..a4d8acd08 100644 --- a/src/main/kotlin/me/odinmain/features/impl/skyblock/RagnarokAxe.kt +++ b/src/main/kotlin/me/odinmain/features/impl/skyblock/RagnarokAxe.kt @@ -26,8 +26,8 @@ object RagnarokAxe : Module( if (it.soundName != "mob.wolf.howl" || it.pitch != 1.4920635f || !isHolding("RAGNAROCK_AXE")) return@onPacket if (alert) PlayerUtils.alert("§aCasted Rag Axe") val strengthGain = ((mc.thePlayer?.heldItem?.getSBStrength ?: return@onPacket) * 1.5).toInt() - if (strengthGainedMessage) modMessage("Gained strength: $strengthGain") - if (announceStrengthGained) partyMessage("Gained strength from rag axe: $strengthGain") + if (strengthGainedMessage) modMessage("§7Gained strength: §4$strengthGain") + if (announceStrengthGained) partyMessage("Gained strength from RagnarokAxe: $strengthGain") } } } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/utils/VecUtils.kt b/src/main/kotlin/me/odinmain/utils/VecUtils.kt index 4f60b40f7..a1bb61232 100644 --- a/src/main/kotlin/me/odinmain/utils/VecUtils.kt +++ b/src/main/kotlin/me/odinmain/utils/VecUtils.kt @@ -14,66 +14,36 @@ import net.minecraft.network.play.server.S2APacketParticles import net.minecraft.util.* import kotlin.math.* - data class Vec2(val x: Int, val z: Int) -data class Vec2f(var x: Float, var y: Float) -data class Vec3f(val x: Float, val y: Float, val z: Float) -data class Vec4f(val x: Float, val y: Float, val z: Float, val w: Float) data class PositionLook(val pos: Vec3, val yaw: Float, val pitch: Float) -operator fun Vec4f.times(mat: Matrix4f): Vec4f { - return Vec4f( - x * mat.m00 + y * mat.m10 + z * mat.m20 + w * mat.m30, - x * mat.m01 + y * mat.m11 + z * mat.m21 + w * mat.m31, - x * mat.m02 + y * mat.m12 + z * mat.m22 + w * mat.m32, - x * mat.m03 + y * mat.m13 + z * mat.m23 + w * mat.m33 - ) -} +fun BlockPos.add(vec: Vec2): BlockPos = this.add(vec.x, 0, vec.z) -fun BlockPos.add(vec: Vec2): BlockPos { - return this.add(vec.x, 0, vec.z) -} -/** - * Gets the distance between two entities squared. - */ -fun Entity.distanceSquaredTo(other: Entity): Double { - return (posX - other.posX).pow(2.0) + (posY - other.posY).pow(2.0) + (posZ - other.posZ).pow(2.0) -} - -fun Entity.distanceSquaredTo(pos: Vec3): Double { - return (posX - pos.xCoord).pow(2.0) + (posY - pos.yCoord).pow(2.0) + (posZ - pos.zCoord).pow(2.0) -} +fun Entity.distanceSquaredTo(pos: Vec3): Double = + (posX - pos.xCoord).pow(2.0) + (posY - pos.yCoord).pow(2.0) + (posZ - pos.zCoord).pow(2.0) /** * Gets the distance between two entities, ignoring y coordinate, squared. */ -fun xzDistance(entity: Entity, entity1: Entity): Double { - return (entity.posX - entity1.posX).pow(2.0) + - (entity.posZ - entity1.posZ).pow(2.0) -} +fun Entity.xzDistance(entity1: Entity): Double = + (posX - entity1.posX).pow(2.0) + (posZ - entity1.posZ).pow(2.0) /** * Gets the eye height of the player * @return The eye height of the player */ -fun fastEyeHeight(): Float { - return if (mc.thePlayer?.isSneaking == true) 1.54f else 1.62f -} +fun fastEyeHeight(): Float = + if (mc.thePlayer?.isSneaking == true) 1.54f else 1.62f /** * Gets the position of the player's eyes * @param pos The position to get the eyes of * @return The position of the player's eyes */ -fun getPositionEyes(pos: Vec3 = mc.thePlayer.positionVector): Vec3 { - return Vec3( - pos.xCoord, - pos.yCoord + fastEyeHeight(), - pos.zCoord - ) -} +fun getPositionEyes(pos: Vec3 = + mc.thePlayer?.positionVector ?: Vec3(0.0, 0.0, 0.0)): Vec3 = Vec3(pos.xCoord, pos.yCoord + fastEyeHeight(), pos.zCoord) /** * Gets a normalized vector of the player's look @@ -81,7 +51,7 @@ fun getPositionEyes(pos: Vec3 = mc.thePlayer.positionVector): Vec3 { * @param pitch The pitch of the player * @return A normalized vector of the player's look */ -fun getLook(yaw: Float = mc.thePlayer.rotationYaw, pitch: Float = mc.thePlayer.rotationPitch): Vec3 { +fun getLook(yaw: Float = mc.thePlayer?.rotationYaw ?: 0f, pitch: Float = mc.thePlayer?.rotationPitch ?: 0f): Vec3 { val f2 = -cos(-pitch * 0.017453292f).toDouble() return Vec3( sin(-yaw * 0.017453292f - 3.1415927f) * f2, @@ -98,9 +68,9 @@ fun getLook(yaw: Float = mc.thePlayer.rotationYaw, pitch: Float = mc.thePlayer.r * @param pitch The pitch of the player * @return True if the given position is being looked at by the player within the given range */ -fun isFacingAABB(aabb: AxisAlignedBB, range: Float, yaw: Float = mc.thePlayer.rotationYaw, pitch: Float = mc.thePlayer.rotationPitch): Boolean { - return isInterceptable(aabb, range, yaw, pitch) -} +fun isFacingAABB(aabb: AxisAlignedBB, range: Float, yaw: Float = mc.thePlayer?.rotationYaw ?: 0f, pitch: Float = mc.thePlayer?.rotationPitch ?: 0f): Boolean = + isInterceptable(aabb, range, yaw, pitch) + /** * Returns true if the given position is being looked at by the player within the given range, ignoring the Y value. @@ -110,13 +80,8 @@ fun isFacingAABB(aabb: AxisAlignedBB, range: Float, yaw: Float = mc.thePlayer.ro * @param pitch The pitch of the player * @return True if the given position is being looked at by the player within the given range, ignoring the Y value */ -fun isXZInterceptable(aabb: AxisAlignedBB, range: Float, pos: Vec3, yaw: Float, pitch: Float): Boolean { - val position = getPositionEyes(pos) - return isXZInterceptable( - position, - position.add(getLook(yaw, pitch).multiply(range)), - aabb - ) +fun isXZInterceptable(aabb: AxisAlignedBB, range: Float, pos: Vec3, yaw: Float, pitch: Float): Boolean = with(getPositionEyes(pos)) { + return isXZInterceptable(this, this.add(getLook(yaw, pitch).multiply(range)), aabb) } private fun isXZInterceptable(start: Vec3, goal: Vec3?, aabb: AxisAlignedBB): Boolean { @@ -131,70 +96,55 @@ private fun isXZInterceptable(start: Vec3, goal: Vec3?, aabb: AxisAlignedBB): Bo * @param factor The factor to multiply by * @return The multiplied Vec3 */ -fun Vec3.multiply(factor: Number): Vec3 { - return Vec3(this.xCoord * factor.toDouble(), this.yCoord * factor.toDouble(), this.zCoord * factor.toDouble()) -} - -fun Vec3.multiply(x: Double = 1.0, y: Double = 1.0, z: Double = 1.0): Vec3 { - return Vec3(this.xCoord * x, this.yCoord * y, this.zCoord * z) -} +fun Vec3.multiply(factor: Number): Vec3 = + Vec3(this.xCoord * factor.toDouble(), this.yCoord * factor.toDouble(), this.zCoord * factor.toDouble()) -/** - * Divides every coordinate of a Vec3 by the given divisor. - * @param divisor The divisor to divide by - * @return The divided Vec3 - */ -fun Vec3.divide(divisor: Number): Vec3 { - return Vec3(this.xCoord / divisor.toDouble(), this.yCoord / divisor.toDouble(), this.zCoord / divisor.toDouble()) -} +fun Vec3.multiply(x: Double = 1.0, y: Double = 1.0, z: Double = 1.0): Vec3 = + Vec3(this.xCoord * x, this.yCoord * y, this.zCoord * z) -fun Vec3.equal(other: Vec3): Boolean { - return this.xCoord == other.xCoord && this.yCoord == other.yCoord && this.zCoord == other.zCoord -} +fun Vec3.equal(other: Vec3): Boolean = + this.xCoord == other.xCoord && this.yCoord == other.yCoord && this.zCoord == other.zCoord /** - * Gets the coordinate of the given index of a Vec3. ( 0 = x, 1 = y, 2 = z ) + * Gets the coordinate of the given index of a Vec3. (0 = x, 1 = y, 2 = z) * @param index The index to get * @return The coordinate of the given index of a Vec3 */ -fun Vec3.get(index: Int): Double { - return when (index) { +operator fun Vec3.get(index: Int): Double = + when (index) { 0 -> this.xCoord 1 -> this.yCoord 2 -> this.zCoord else -> throw IndexOutOfBoundsException("Index: $index, Size: 3") } -} /** * Rotates a Vec3 around the given rotation. * @param rotation The rotation to rotate around * @return The rotated Vec3 */ -fun Vec3.rotateAroundNorth(rotation: Rotations): Vec3 { - return when (rotation) { +fun Vec3.rotateAroundNorth(rotation: Rotations): Vec3 = + when (rotation) { Rotations.NORTH -> Vec3(-this.xCoord, this.yCoord, -this.zCoord) - Rotations.WEST -> Vec3(-this.zCoord, this.yCoord, this.xCoord) + Rotations.WEST -> Vec3(-this.zCoord, this.yCoord, this.xCoord) Rotations.SOUTH -> Vec3(this.xCoord, this.yCoord, this.zCoord) - Rotations.EAST -> Vec3(this.zCoord, this.yCoord, -this.xCoord) + Rotations.EAST -> Vec3(this.zCoord, this.yCoord, -this.xCoord) else -> this } -} /** * Rotates a Vec3 to the given rotation. * @param rotation The rotation to rotate to * @return The rotated Vec3 */ -fun Vec3.rotateToNorth(rotation: Rotations): Vec3 { - return when (rotation) { +fun Vec3.rotateToNorth(rotation: Rotations): Vec3 = + when (rotation) { Rotations.NORTH -> Vec3(-this.xCoord, this.yCoord, -this.zCoord) - Rotations.WEST -> Vec3(this.zCoord, this.yCoord, -this.xCoord) + Rotations.WEST -> Vec3(this.zCoord, this.yCoord, -this.xCoord) Rotations.SOUTH -> Vec3(this.xCoord, this.yCoord, this.zCoord) - Rotations.EAST -> Vec3(-this.zCoord, this.yCoord, this.xCoord) + Rotations.EAST -> Vec3(-this.zCoord, this.yCoord, this.xCoord) else -> this } -} /** * Checks if an axis-aligned bounding box (AABB) is interceptable based on the player's position, range, yaw, and pitch. @@ -205,12 +155,8 @@ fun Vec3.rotateToNorth(rotation: Rotations): Vec3 { * @param pitch The pitch angle. * @return `true` if the AABB is interceptable, `false` otherwise. */ -private fun isInterceptable(aabb: AxisAlignedBB, range: Float, yaw: Float, pitch: Float): Boolean { - mc.thePlayer?.let { player -> - val position = Vec3(player.posX, player.posY + fastEyeHeight(), player.posZ) - return isInterceptable3(position, position.add(getLook(yaw, pitch).multiply(range)), aabb) - } - return false +private fun isInterceptable(aabb: AxisAlignedBB, range: Float, yaw: Float, pitch: Float): Boolean = with(getPositionEyes()) { + return isInterceptable3(this, this.add(getLook(yaw, pitch).multiply(range)), aabb) } /** @@ -224,16 +170,14 @@ private fun isInterceptable(aabb: AxisAlignedBB, range: Float, yaw: Float, pitch private fun isInterceptable3(start: Vec3, goal: Vec3, aabb: AxisAlignedBB): Boolean { return try { ( - isVecInYZ(start.getIntermediateWithXValue(goal, aabb.minX), aabb) || - isVecInYZ(start.getIntermediateWithXValue(goal, aabb.maxX), aabb) || - isVecInXZ(start.getIntermediateWithYValue(goal, aabb.minY), aabb) || - isVecInXZ(start.getIntermediateWithYValue(goal, aabb.maxY), aabb) || - isVecInXY(start.getIntermediateWithZValue(goal, aabb.minZ), aabb) || - isVecInXY(start.getIntermediateWithZValue(goal, aabb.maxZ), aabb) + isVecInYZ(start.getIntermediateWithXValue(goal, aabb.minX), aabb) || + isVecInYZ(start.getIntermediateWithXValue(goal, aabb.maxX), aabb) || + isVecInXZ(start.getIntermediateWithYValue(goal, aabb.minY), aabb) || + isVecInXZ(start.getIntermediateWithYValue(goal, aabb.maxY), aabb) || + isVecInXY(start.getIntermediateWithZValue(goal, aabb.minZ), aabb) || + isVecInXY(start.getIntermediateWithZValue(goal, aabb.maxZ), aabb) ) - } catch (_: Exception) { - false - } + } catch (_: Exception) { false } } /** @@ -292,98 +236,83 @@ private fun isVecInX(vec: Vec3?, aabb: AxisAlignedBB): Boolean = * @param vec3 The Vec3 to add to the current Vec3. * @return A new Vec3 representing the sum of the two vectors. */ -operator fun Vec3.plus(vec3: Vec3): Vec3 { - return this.add(vec3) -} +operator fun Vec3.plus(vec3: Vec3): Vec3 = + this.add(vec3) /** * Adds the given coordinates to the Vec3. */ -fun Vec3.addVec(x: Number = .0, y: Number = .0, z: Number = .0): Vec3 { - return this.addVector(x.toDouble(), y.toDouble(), z.toDouble()) -} +fun Vec3.addVec(x: Number = .0, y: Number = .0, z: Number = .0): Vec3 = + this.addVector(x.toDouble(), y.toDouble(), z.toDouble()) /** * Removes the given coordinates to the Vec3. */ -fun Vec3.subtractVec(x: Number = .0, y: Number = .0, z: Number = .0): Vec3 { - return this.addVector(-x.toDouble(), -y.toDouble(), -z.toDouble()) -} +fun Vec3.subtractVec(x: Number = .0, y: Number = .0, z: Number = .0): Vec3 = + this.addVector(-x.toDouble(), -y.toDouble(), -z.toDouble()) /** * Adds the given coordinates to the Vec3. */ -fun Vec3i.addVec(x: Number = .0, y: Number = .0, z: Number = .0): Vec3i { - return Vec3i(this.x + x.toInt(), this.y + y.toInt(), this.z + z.toInt()) -} +fun Vec3i.addVec(x: Number = .0, y: Number = .0, z: Number = .0): Vec3i = + Vec3i(this.x + x.toInt(), this.y + y.toInt(), this.z + z.toInt()) + /** * Floors every coordinate of a Vec3 and turns it into a Vec3i. */ -fun Vec3.floored(): Vec3i { - return Vec3i(xCoord.floor().toDouble(), yCoord.floor().toDouble(), zCoord.floor().toDouble()) -} +fun Vec3.floored(): Vec3i = + Vec3i(xCoord.floor(), yCoord.floor(), zCoord.floor()) + /** * Floors every coordinate of a Vec3 */ -fun Vec3.flooredVec(): Vec3 { - return Vec3(xCoord.floor().toDouble(), yCoord.floor().toDouble(), zCoord.floor().toDouble()) -} +fun Vec3.flooredVec(): Vec3 = + Vec3(xCoord.floor(), yCoord.floor(), zCoord.floor()) /** * @param add Will determine the maximum bounds */ -fun BlockPos.toAABB(add: Double = 1.0): AxisAlignedBB { - return AxisAlignedBB(this.x.toDouble(), this.y.toDouble(), this.z.toDouble(), this.x + add, this.y + add, this.z + add).outlineBounds() -} +fun BlockPos.toAABB(add: Double = 1.0): AxisAlignedBB = + AxisAlignedBB(this.x.toDouble(), this.y.toDouble(), this.z.toDouble(), this.x + add, this.y + add, this.z + add).outlineBounds() /** * @param add Will determine the maximum bounds */ -fun Vec3.toAABB(add: Double = 1.0): AxisAlignedBB { - return AxisAlignedBB(this.xCoord, this.yCoord, this.zCoord, this.xCoord + add, this.yCoord + add, this.zCoord + add).outlineBounds() -} +fun Vec3.toAABB(add: Double = 1.0): AxisAlignedBB = + AxisAlignedBB(this.xCoord, this.yCoord, this.zCoord, this.xCoord + add, this.yCoord + add, this.zCoord + add).outlineBounds() /** * Turns a Vec3 into a BlockPos. */ -fun Vec3.toBlockPos(add: Double = 0.0): BlockPos { - return BlockPos(this.xCoord + add, this.yCoord + add, this.zCoord + add) -} +fun Vec3.toBlockPos(add: Double = 0.0): BlockPos = + BlockPos(this.xCoord + add, this.yCoord + add, this.zCoord + add) + /** * Clones a Vec3 object. */ -fun Vec3.clone(): Vec3 = Vec3(this.xCoord, this.yCoord, this.zCoord) +fun Vec3.clone(): Vec3 = + Vec3(this.xCoord, this.yCoord, this.zCoord) /** * Turns a Vec3 into a double array. */ -fun Vec3.toDoubleArray(): DoubleArray { - return doubleArrayOf(xCoord, yCoord, zCoord) -} - -/** - * Turns a BlockPos into a Vec3i. - */ -fun BlockPos.toVec3i(): Vec3i { - return Vec3i(x, y, z) -} +fun Vec3.toDoubleArray(): DoubleArray = + doubleArrayOf(xCoord, yCoord, zCoord) /** * Turns a BlockPos into a Vec3. */ -fun BlockPos.toVec3(): Vec3 { - return Vec3(x.toDouble(), y.toDouble(), z.toDouble()) -} +fun BlockPos.toVec3(): Vec3 = + Vec3(x.toDouble(), y.toDouble(), z.toDouble()) /** * Turns a double array into a Vec3. */ -fun DoubleArray.toVec3(): Vec3 { - return Vec3(this[0], this[1], this[2]) -} +fun DoubleArray.toVec3(): Vec3 = + Vec3(this[0], this[1], this[2]) /** * Solves the equation for diana burrow estimate. @@ -397,58 +326,36 @@ fun calculateCoefficientsFromVectors(x: Vec3, y: Vec3): Triple - get() = listOf( +val AxisAlignedBB.corners: List get() = + listOf( Vec3(minX, minY, minZ), Vec3(minX, maxY, minZ), Vec3(maxX, maxY, minZ), Vec3(maxX, minY, minZ), Vec3(minX, minY, maxZ), Vec3(minX, maxY, maxZ), Vec3(maxX, maxY, maxZ), Vec3(maxX, minY, maxZ) ) -operator fun Vec3.unaryMinus(): Vec3 = Vec3(-xCoord, -yCoord, -zCoord) +operator fun Vec3.unaryMinus(): Vec3 = + Vec3(-xCoord, -yCoord, -zCoord) -fun AxisAlignedBB.offset(vec: Vec3) = AxisAlignedBB( - this.minX + vec.xCoord, this.minY + vec.yCoord, this.minZ + vec.zCoord, this.maxX + vec.xCoord, this.maxY + vec.yCoord, this.maxZ + vec.zCoord -) +fun AxisAlignedBB.offset(vec: Vec3) = + AxisAlignedBB(this.minX + vec.xCoord, this.minY + vec.yCoord, this.minZ + vec.zCoord, this.maxX + vec.xCoord, this.maxY + vec.yCoord, this.maxZ + vec.zCoord) -val AxisAlignedBB.middle: Vec3 - get() = Vec3(this.minX + (this.maxX - this.minX) / 2, this.minY + (this.maxY - this.minY) / 2, this.minZ + (this.maxZ - this.minZ) / 2) +val AxisAlignedBB.middle: Vec3 get() = + Vec3(this.minX + (this.maxX - this.minX) / 2, this.minY + (this.maxY - this.minY) / 2, this.minZ + (this.maxZ - this.minZ) / 2) /** * Finds the nearest grass block to the given position. @@ -468,21 +375,17 @@ fun findNearestGrassBlock(pos: Vec3): Vec3 { /** * Returns Triple(distance, yaw, pitch) in minecraft coordinate system to get from x0y0z0 to x1y1z1. * - * @param x0 X coordinate of the first point - * @param y0 Y coordinate of the first point - * @param z0 Z coordinate of the first point + * @param vec3 Vec3 to get direction to. * - * @param x1 X coordinate of the second point - * @param y1 Y coordinate of the second point - * @param z1 Z coordinate of the second point + * @param vec31 Vec3 to get direction from. * * @return Triple of distance, yaw, pitch * @author Aton */ -fun getDirection(x0: Double, y0: Double, z0: Double, x1: Double, y1: Double, z1: Double): Triple { - val dist = sqrt((x1 - x0).pow(2) + (y1 - y0).pow(2) + (z1 - z0).pow(2)) - val yaw = -atan2((x1-x0), (z1-z0)) / Math.PI * 180 - val pitch = -atan2((y1-y0), sqrt((x1 - x0).pow(2) + (z1 - z0).pow(2))) / Math.PI*180 +fun getDirection(vec3: Vec3, vec31: Vec3): Triple { + val dist = sqrt((vec31.xCoord - vec3.xCoord).pow(2) + (vec31.yCoord - vec3.yCoord).pow(2) + (vec31.zCoord - vec3.zCoord).pow(2)) + val yaw = -atan2((vec31.xCoord - vec3.xCoord), (vec31.zCoord - vec3.zCoord)) / Math.PI * 180 + val pitch = -atan2((vec31.yCoord - vec3.yCoord), sqrt((vec31.xCoord - vec3.xCoord).pow(2) + (vec31.zCoord - vec3.zCoord).pow(2))) / Math.PI * 180 return Triple(dist, yaw.toFloat() % 360f, pitch.toFloat() % 360f) } @@ -494,9 +397,8 @@ fun getDirection(x0: Double, y0: Double, z0: Double, x1: Double, y1: Double, z1: * @return Triple of distance, yaw, pitch * @author Bonsai */ -fun getDirectionToVec3(pos: Vec3): Triple { - return getDirection(mc.thePlayer.posX, mc.thePlayer.posY + fastEyeHeight(), mc.thePlayer.posZ, pos.xCoord, pos.yCoord, pos.zCoord) -} +fun getDirectionToVec3(pos: Vec3): Triple = + getDirection(getPositionEyes(), pos) /** * Returns a triple of distance, yaw, pitch to rotate to the given position with etherwarp physics, or null if etherwarp is not possible. @@ -548,12 +450,7 @@ fun etherwarpRotateTo(targetPos: BlockPos, dist: Double = 61.0): Triple 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) +fun BlockPos.addRotationCoords(rotation: Rotations, x: Int, z: Int): BlockPos = + when (rotation) { + Rotations.NORTH -> BlockPos(this.x + x, this.y, this.z + z) + Rotations.SOUTH -> BlockPos(this.x - x, this.y, this.z - z) + Rotations.WEST -> BlockPos(this.x + z, this.y, this.z - x) + Rotations.EAST -> BlockPos(this.x - z, this.y, this.z + x) else -> this - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/DianaBurrowEstimate.kt b/src/main/kotlin/me/odinmain/utils/skyblock/DianaBurrowEstimate.kt index 6aff25938..9625f5fdf 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/DianaBurrowEstimate.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/DianaBurrowEstimate.kt @@ -58,9 +58,8 @@ object DianaBurrowEstimate { removeBurrow(pos, force = true) } - fun chat(message: String) { - if (message.startsWith("You dug out a Griffin Burrow!") || message == "You finished the Griffin burrow chain! (4/4)") - lastDugBurrow?.let { if (!removeBurrow(it)) pendingBurrow = it } + fun onBurrowDug() { + lastDugBurrow?.let { if (!removeBurrow(it)) pendingBurrow = it } } private fun removeBurrow(location: BlockPos, force: Boolean = false): Boolean { diff --git a/src/main/kotlin/me/odinmain/utils/skyblock/EtherWarpHelper.kt b/src/main/kotlin/me/odinmain/utils/skyblock/EtherWarpHelper.kt index 30199ac4f..b3e1473fe 100644 --- a/src/main/kotlin/me/odinmain/utils/skyblock/EtherWarpHelper.kt +++ b/src/main/kotlin/me/odinmain/utils/skyblock/EtherWarpHelper.kt @@ -43,25 +43,26 @@ object EtherWarpHelper { */ private fun traverseVoxels(start: Vec3, end: Vec3): EtherPos { val direction = end.subtract(start) - val step = DoubleArray(3) { sign(direction.get(it)) } - val invDirection = DoubleArray(3) { 1.0 / direction.get(it) } + val step = IntArray(3) { sign(direction[it]).toInt() } + val invDirection = DoubleArray(3) { if (direction[it] != 0.0) 1.0 / direction[it] else Double.MAX_VALUE } val tDelta = DoubleArray(3) { invDirection[it] * step[it] } + val currentPos = IntArray(3) { floor(start[it]).toInt() } + val endPos = IntArray(3) { floor(end[it]).toInt() } val tMax = DoubleArray(3) { - val startCoord = start.get(it) - abs((floor(startCoord) + max(step[it], 0.0) - startCoord) * invDirection[it]) + val startCoord = start[it] + abs((floor(startCoord) + max(step[it], 0) - startCoord) * invDirection[it]) } - val currentPos = DoubleArray(3) { floor(start.get(it)) } - val endPos = DoubleArray(3) { floor(end.get(it)) } - var iterations = 0 - - while (iterations++ < 1000) { - val pos = BlockPos(currentPos[0].toInt(), currentPos[1].toInt(), currentPos[2].toInt()) + repeat(1000) { + val pos = BlockPos(currentPos[0], currentPos[1], currentPos[2]) if (getBlockIdAt(pos) != 0) return EtherPos(isValidEtherWarpBlock(pos), pos) + if (currentPos.contentEquals(endPos)) return EtherPos.NONE - if (currentPos.contentEquals(endPos)) break // reached end + val minIndex = if (tMax[0] <= tMax[1]) + if (tMax[0] <= tMax[2]) 0 else 2 + else + if (tMax[1] <= tMax[2]) 1 else 2 - val minIndex = tMax.indices.minByOrNull { tMax[it] } ?: 0 tMax[minIndex] += tDelta[minIndex] currentPos[minIndex] += step[minIndex] } 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 07f060c21..498364764 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 @@ -7,7 +7,6 @@ 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 @@ -21,16 +20,12 @@ data class Room( 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()) + val blockPos = BlockPos(x, 70, z) } data class RoomData( - val name: String, - val type: RoomType, - val cores: List, - val crypts: Int, - val secrets: Int, - val trappedChests: Int, + val name: String, val type: RoomType, val cores: List, + val crypts: Int, val secrets: Int, val trappedChests: Int, ) class RoomDataDeserializer : JsonDeserializer {