From 3f5e7acc0fa3086c25879ccf4c668f6e77da9457 Mon Sep 17 00:00:00 2001 From: illyum <90023277+itzilly@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:14:42 -0600 Subject: [PATCH] feat(chestesp): add initial implementation, halfway done Adds ChestESP features, only toggles on. There is no off toggle, and once a block is highlighted it will remain highlighted --- .../com/github/itzilly/sbt/SkyBlockTweaks.kt | 80 +++++++++++++++---- src/main/resources/assets/sbt/lang/en_US.lang | 4 +- 2 files changed, 69 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt b/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt index 1ec9c53..aaa64ab 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt @@ -12,6 +12,7 @@ import net.minecraft.client.settings.KeyBinding import net.minecraft.command.CommandException import net.minecraft.command.ICommandSender import net.minecraft.entity.Entity +import net.minecraft.init.Blocks import net.minecraft.util.AxisAlignedBB import net.minecraft.util.BlockPos import net.minecraft.util.ChatComponentText @@ -112,6 +113,7 @@ object STBKeyBinds { lateinit var finishWaypoints: KeyBinding lateinit var clearWaypoints: KeyBinding lateinit var openRoutesGui: KeyBinding + lateinit var xrayChests: KeyBinding fun init() { addWaypoint = KeyBinding("key.addWaypoint", Keyboard.KEY_ADD, "key.categories.sbt") @@ -125,6 +127,9 @@ object STBKeyBinds { openRoutesGui = KeyBinding("key.openRoutesGui", Keyboard.KEY_O, "key.categories.sbt") ClientRegistry.registerKeyBinding(openRoutesGui) + + xrayChests = KeyBinding("key.xrayToggle", Keyboard.KEY_I, "key.categories.sbt") + ClientRegistry.registerKeyBinding(xrayChests) } } @@ -148,21 +153,61 @@ class KeyInputHandler { mc.thePlayer.addChatMessage(ChatComponentText("Point ($x, $y, $z) is already in the route list")) } - } - else if (STBKeyBinds.finishWaypoints.isPressed) { + } else if (STBKeyBinds.finishWaypoints.isPressed) { mc.thePlayer.addChatMessage(ChatComponentText("Finished route! Copied route to clipboard")) val jsonString = Gson().toJson(SkyBlockTweaks.routeList) setClipboard(jsonString) SkyBlockTweaks.routeList.clear() - } - else if (STBKeyBinds.clearWaypoints.isPressed) { + } else if (STBKeyBinds.clearWaypoints.isPressed) { SkyBlockTweaks.routeList.clear() mc.thePlayer.addChatMessage(ChatComponentText("Reset current route")) - } - else if (STBKeyBinds.openRoutesGui.isPressed) { + } else if (STBKeyBinds.openRoutesGui.isPressed) { mc.displayGuiScreen(RouteGui()) + } else if (STBKeyBinds.xrayChests.isPressed) { + highlightChests() } } + + private fun highlightChests() { + val searchRadius = 8 + val world = Minecraft.getMinecraft().thePlayer.worldObj + val posX = Minecraft.getMinecraft().thePlayer.posX + val posY = Minecraft.getMinecraft().thePlayer.posY + val posZ = Minecraft.getMinecraft().thePlayer.posZ + + val boundXMax = posX + searchRadius + val boundXMin = posX - searchRadius + + val boundYMax = posY + searchRadius + val boundYMin = posY - searchRadius + + val boundZMax = posZ + searchRadius + val boundZMin = posZ - searchRadius + + val maxMarker = + RouteMarker(boundXMax.toInt(), boundYMax.toInt(), boundZMax.toInt(), 1u, 0u, 0u, RouteOptions("Max Bounds")) + val minMarker = + RouteMarker(boundXMin.toInt(), boundYMin.toInt(), boundZMin.toInt(), 0u, 1u, 0u, RouteOptions("Min Bounds")) + + Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("Searching...")) + // Loop over each block in the defined bounds + for (x in boundXMin.toInt()..boundXMax.toInt()) { + for (y in boundYMin.toInt()..boundYMax.toInt()) { + for (z in boundZMin.toInt()..boundZMax.toInt()) { + // Get the block at the current coordinates + val block = world.getBlockState(BlockPos(x, y, z)).block + if (block == Blocks.chest || block == Blocks.trapped_chest || block == Blocks.ender_chest) { + val point = RouteMarker(x, y, z, 0u, 0u, 1u, RouteOptions("Located point")) + SkyBlockTweaks.routeList.add(point) + } + } + } + } + Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("Done!")) + +// SkyBlockTweaks.routeList.add(maxMarker) +// SkyBlockTweaks.routeList.add(minMarker) + } } data class RouteMarker( @@ -220,8 +265,10 @@ fun renderPoint(entity: Entity, blockPos: BlockPos, partialTicks: Float) { // Create a default bounding box for blocks that don't have one val boundingBox: AxisAlignedBB = block.getCollisionBoundingBox(world, blockPos, blockState) - ?: AxisAlignedBB(blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), - blockPos.x + 1.0, blockPos.y + 1.0, blockPos.z + 1.0).expand(padding, padding, padding) + ?: AxisAlignedBB( + blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), + blockPos.x + 1.0, blockPos.y + 1.0, blockPos.z + 1.0 + ).expand(padding, padding, padding) GL11.glPushMatrix() GlStateManager.disableTexture2D() @@ -287,13 +334,18 @@ class RouteGui : GuiScreen() { buttonList.clear() populateRouteList() - buttonList.add(RouteMarkerButton(9000, width/2 + 20, height - 40, "Exit")) + buttonList.add(RouteMarkerButton(9000, width / 2 + 20, height - 40, "Exit")) } override fun actionPerformed(button: GuiButton?) { - if (button == null) { return } - if (button.id < 1000) { buttonList.remove(button) } - else if (button.id == 9000) { Minecraft.getMinecraft().thePlayer.closeScreen() } + if (button == null) { + return + } + if (button.id < 1000) { + buttonList.remove(button) + } else if (button.id == 9000) { + Minecraft.getMinecraft().thePlayer.closeScreen() + } } override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { @@ -303,9 +355,9 @@ class RouteGui : GuiScreen() { private fun populateRouteList() { for ((buttonId, m: RouteMarker) in SkyBlockTweaks.routeList.withIndex()) { - val markerField = GuiTextField(1000 + buttonId, fontRendererObj, width/2 - 200, 0, 100, 20) + val markerField = GuiTextField(1000 + buttonId, fontRendererObj, width / 2 - 200, 0, 100, 20) markerField.text = "${m.options.name} X:${m.x} Y:${m.y} Z:${m.z}" - val removeButton = RouteMarkerButton(2000 + buttonId, width/2 + 175, 0, 50, 20, "Remove") + val removeButton = RouteMarkerButton(2000 + buttonId, width / 2 + 175, 0, 50, 20, "Remove") buttonList.add(removeButton) } } diff --git a/src/main/resources/assets/sbt/lang/en_US.lang b/src/main/resources/assets/sbt/lang/en_US.lang index 4bb98c7..4c517ba 100644 --- a/src/main/resources/assets/sbt/lang/en_US.lang +++ b/src/main/resources/assets/sbt/lang/en_US.lang @@ -1,4 +1,6 @@ key.categories.sbt=SkyBlock Tweaks key.addWaypoint=Add Route Point key.finishWaypoints=Finish Route -key.clearWaypoints=Clear Route Points \ No newline at end of file +key.clearWaypoints=Clear Route Points +key.openRoutesGui=Open Route GUI +key.xrayToggle=Toggle ChestESP \ No newline at end of file