diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-09-25 21:09:08 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-09-25 21:09:25 -0400 |
commit | 4c1c465ce0f8a3209c4856cbc4d370cd0ce3e19b (patch) | |
tree | eba154b9cd2cc29380e7b967e33be2509e66573b /src/main | |
parent | a97207bfb26b2f00b8551c5984122c8c4a150601 (diff) | |
download | SkytilsMod-4c1c465ce0f8a3209c4856cbc4d370cd0ce3e19b.tar.gz SkytilsMod-4c1c465ce0f8a3209c4856cbc4d370cd0ce3e19b.tar.bz2 SkytilsMod-4c1c465ce0f8a3209c4856cbc4d370cd0ce3e19b.zip |
my brain is probably more dead than this tp maze solver
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/TeleportMazeSolver.kt | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/TeleportMazeSolver.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/TeleportMazeSolver.kt index 1f642ae9..24d37b24 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/TeleportMazeSolver.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/solvers/TeleportMazeSolver.kt @@ -17,7 +17,8 @@ */ package skytils.skytilsmod.features.impl.dungeons.solvers -import net.minecraft.client.Minecraft +import gg.essential.elementa.utils.withAlpha +import gg.essential.universal.UChat import net.minecraft.client.renderer.GlStateManager import net.minecraft.init.Blocks import net.minecraft.util.AxisAlignedBB @@ -28,11 +29,32 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent import skytils.skytilsmod.Skytils +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.events.SendChatMessageEvent import skytils.skytilsmod.listeners.DungeonListener +import skytils.skytilsmod.utils.DevTools import skytils.skytilsmod.utils.RenderUtil import skytils.skytilsmod.utils.Utils +import java.awt.Color class TeleportMazeSolver { + + companion object { + private val steppedPads = ArrayList<BlockPos>() + private var lastTpPos: BlockPos? = null + val poss = HashSet<BlockPos>() + } + + @SubscribeEvent + fun onSendMsg(event: SendChatMessageEvent) { + if (DevTools.getToggle("tpmaze") && event.message == "/resettp") { + lastTpPos = null + steppedPads.clear() + poss.clear() + event.isCanceled = true + } + } + @SubscribeEvent fun onTick(event: ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return @@ -48,12 +70,36 @@ class TeleportMazeSolver { Utils.getBlocksWithinRangeAtSameY(lastTpPos!!, 1, 69).find { mc.theWorld.getBlockState(it).block === Blocks.end_portal_frame }?.let { - steppedPads.add(it) + if (!steppedPads.contains(it)) steppedPads.add(it) } Utils.getBlocksWithinRangeAtSameY(groundBlock, 1, 69).find { mc.theWorld.getBlockState(it).block === Blocks.end_portal_frame - }?.let { - steppedPads.add(it) + }?.let { pos -> + if (!steppedPads.contains(pos)) { + steppedPads.add(pos) + val vec = mc.thePlayer.lookVec.normalize() + val valid = HashSet<BlockPos>() + for (i in 4..23) { + val bp = BlockPos( + mc.thePlayer.posX + vec.xCoord * i, + 69.0, + mc.thePlayer.posZ + vec.zCoord * i + ) + val allDir = Utils.getBlocksWithinRangeAtSameY(bp, 2, 69) + + if (allDir.none { it == mc.thePlayer.position }) { + valid.addAll(allDir.filter { it !in steppedPads && mc.theWorld.getBlockState(it).block === Blocks.end_portal_frame }) + } + } + if (DevTools.getToggle("tpmaze")) UChat.chat(valid.joinToString { it.toString() }) + if (poss.isEmpty()) { + poss.addAll(valid) + } else { + poss.removeAll { + it !in valid + } + } + } } } } @@ -78,17 +124,25 @@ class TeleportMazeSolver { ) GlStateManager.enableCull() } + + for (pos in poss) { + val x = pos.x - viewerX + val y = pos.y - viewerY + val z = pos.z - viewerZ + GlStateManager.disableCull() + RenderUtil.drawFilledBoundingBox( + AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1).expand(0.01, 0.01, 0.01), + Color.GREEN.withAlpha(69), + 1f + ) + GlStateManager.enableCull() + } } @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { steppedPads.clear() lastTpPos = null - } - - companion object { - private val mc = Minecraft.getMinecraft() - private val steppedPads = HashSet<BlockPos>() - private var lastTpPos: BlockPos? = null + poss.clear() } }
\ No newline at end of file |