From fbaab2536f975d38bf2d3672afb846f9ab79e51f Mon Sep 17 00:00:00 2001 From: illyum <90023277+itzilly@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:21:07 -0600 Subject: [PATCH] ChestESP, Route Builder, Chatterbox, Gemstone Finder, Grotto Finder --- gradle.properties | 2 +- .../kotlin/com/github/itzilly/sbt/HudText.kt | 24 --- .../com/github/itzilly/sbt/InputHandler.kt | 48 +++++ .../com/github/itzilly/sbt/SBTKeybinds.kt | 34 ++++ .../com/github/itzilly/sbt/STBKeyBindings.kt | 51 ------ .../com/github/itzilly/sbt/SkyBlockTweaks.kt | 121 ++---------- .../github/itzilly/sbt/features/ChestEsp.kt | 173 ++++++++++++++++++ .../itzilly/sbt/features/GemstoneFinder.kt | 108 +++++++++++ .../itzilly/sbt/features/GrottoFinder.kt | 88 +++++++++ .../mining/lockedChestESP/LockedChestEsp.kt | 113 ------------ .../features/mining/routeMaker/GuiStuff.kt | 83 --------- .../features/mining/routeMaker/RouteMaker.kt | 5 - .../mining/routeMaker/RouteMarkerRender.kt | 85 --------- .../itzilly/sbt/features/router/RootMarker.kt | 1 + .../sbt/features/{ => router}/RouteBuilder.kt | 31 +++- .../RouteMarker.kt => router/RouteMaker.kt} | 5 +- .../itzilly/sbt/mixin/MixinGuiMainMenu.java | 4 +- .../sbt/mixin/RenderManagerAccessor.kt | 7 - .../itzilly/sbt/mixin/RenderManagerMixin.kt | 22 --- .../kotlin/com/github/itzilly/sbt/mycrap.kt | 95 ---------- .../RenderFuncs.kt} | 68 +++++-- .../itzilly/sbt/renderer/RenderUtils.kt | 1 + .../com/github/itzilly/sbt/util/Chatterbox.kt | 5 + .../itzilly/sbt/util/MessageScheduler.kt | 22 +++ 24 files changed, 576 insertions(+), 620 deletions(-) delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/HudText.kt create mode 100644 src/main/kotlin/com/github/itzilly/sbt/InputHandler.kt create mode 100644 src/main/kotlin/com/github/itzilly/sbt/SBTKeybinds.kt delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/STBKeyBindings.kt create mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/ChestEsp.kt create mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/GemstoneFinder.kt create mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/GrottoFinder.kt delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/LockedChestEsp.kt delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/GuiStuff.kt delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMaker.kt delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarkerRender.kt create mode 100644 src/main/kotlin/com/github/itzilly/sbt/features/router/RootMarker.kt rename src/main/kotlin/com/github/itzilly/sbt/features/{ => router}/RouteBuilder.kt (76%) rename src/main/kotlin/com/github/itzilly/sbt/features/{mining/routeMaker/RouteMarker.kt => router/RouteMaker.kt} (74%) delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerAccessor.kt delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerMixin.kt delete mode 100644 src/main/kotlin/com/github/itzilly/sbt/mycrap.kt rename src/main/kotlin/com/github/itzilly/sbt/{features/mining/lockedChestESP/ChestESPRender.kt => renderer/RenderFuncs.kt} (54%) create mode 100644 src/main/kotlin/com/github/itzilly/sbt/util/MessageScheduler.kt diff --git a/gradle.properties b/gradle.properties index ef07eac..267ef8e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g baseGroup = com.github.itzilly.sbt mcVersion = 1.8.9 modid = sbt -version = 1.0.1 +version = 1.4.0 diff --git a/src/main/kotlin/com/github/itzilly/sbt/HudText.kt b/src/main/kotlin/com/github/itzilly/sbt/HudText.kt deleted file mode 100644 index d2f1a58..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/HudText.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.github.itzilly.sbt - -import net.minecraft.client.renderer.GlStateManager -import java.util.* - -//class HudText(var textLines: Array, var x: Int, var y: Int, var shadow: Boolean) : RenderHudAble { -// var scale = 1f -// val id = UUID.randomUUID() -// override fun render(partialTicks: Float) { -// GlStateManager.pushMatrix() -// GlStateManager.translate(x.toFloat(), y.toFloat(), 0f) -// GlStateManager.scale(scale, scale, scale) -// var yOff = 0 -// for (line in textLines) { -// if (shadow) { -// SkyBlockTweaks.INSTANCE.fontRenderer.drawStringWithShadow(line, 0f, yOff.toFloat(), 0) -// } else { -// SkyBlockTweaks.INSTANCE.fontRenderer.drawString(line, 0, yOff, 0) -// } -// yOff += 10 -// } -// GlStateManager.popMatrix() -// } -//} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/InputHandler.kt b/src/main/kotlin/com/github/itzilly/sbt/InputHandler.kt new file mode 100644 index 0000000..8fead45 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/InputHandler.kt @@ -0,0 +1,48 @@ +package com.github.itzilly.sbt + +import com.github.itzilly.sbt.features.ChestEsp +import com.github.itzilly.sbt.features.GemstoneFinder +import com.github.itzilly.sbt.features.GrottoFinder +import com.github.itzilly.sbt.util.Chatterbox +import com.github.itzilly.sbt.util.SimpleChatMsg +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.InputEvent + +class InputHandler { + @SubscribeEvent + fun onKeyInput(event: InputEvent.KeyInputEvent?) { + if (STBKeyBinds.searchForChests.isPressed) { + ChestEsp.highlightChests() + } + if (STBKeyBinds.clearChests.isPressed) { + ChestEsp.chestList.clear() + Chatterbox.say(SimpleChatMsg("Chests cleared").green()) + } + if (STBKeyBinds.toggleGrottoFinder.isPressed) { + Chatterbox.say("Running check...") + GrottoFinder.checkWorldForMagentaStainedGlass(Minecraft.getMinecraft().thePlayer.worldObj) + Chatterbox.say("Check done") +// if (GrottoFinder.isEnabled) { +// GrottoFinder.isEnabled = false +// Chatterbox.say(SimpleChatMsg("Grotto finder disabled!").red()) +// MinecraftForge.EVENT_BUS.register(GrottoFinder) +// } else { +// GrottoFinder.isEnabled = true +// Chatterbox.say(SimpleChatMsg("Grotto finder enabled!").green()) +// // MinecraftForge.EVENT_BUS.unregister(GrottoFinder) +// } + + } + if (STBKeyBinds.clearGrotto.isPressed) { + GrottoFinder.clear() + Chatterbox.say("Cleared grotto finder") + } + if (STBKeyBinds.findGemstones.isPressed) { + GemstoneFinder.find() + } + if (STBKeyBinds.clearGemstones.isPressed) { + GemstoneFinder.clear() + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/SBTKeybinds.kt b/src/main/kotlin/com/github/itzilly/sbt/SBTKeybinds.kt new file mode 100644 index 0000000..12dd487 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/SBTKeybinds.kt @@ -0,0 +1,34 @@ +package com.github.itzilly.sbt + +import net.minecraft.client.settings.KeyBinding +import net.minecraftforge.fml.client.registry.ClientRegistry +import org.lwjgl.input.Keyboard + +object STBKeyBinds { + lateinit var searchForChests: KeyBinding + lateinit var clearChests: KeyBinding + lateinit var toggleGrottoFinder: KeyBinding + lateinit var clearGrotto: KeyBinding + lateinit var findGemstones: KeyBinding + lateinit var clearGemstones: KeyBinding + + fun init() { + searchForChests = KeyBinding("key.xraySearch", Keyboard.KEY_F10, "key.categories.sbt") + ClientRegistry.registerKeyBinding(searchForChests) + + clearChests = KeyBinding("key.xrayClear", Keyboard.KEY_MINUS, "key.categories.sbt") + ClientRegistry.registerKeyBinding(clearChests) + + toggleGrottoFinder = KeyBinding("key.toggleGrottoFinder", Keyboard.KEY_N, "key.categories.sbt") + ClientRegistry.registerKeyBinding(toggleGrottoFinder) + + clearGrotto = KeyBinding("key.clearGrotto", Keyboard.KEY_F1, "key.categories.sbt") + ClientRegistry.registerKeyBinding(clearGrotto) + + findGemstones = KeyBinding("key.findGemstones", Keyboard.KEY_J, "key.categories.sbt") + ClientRegistry.registerKeyBinding(findGemstones) + + clearGemstones = KeyBinding("key.clearGemstones", Keyboard.KEY_K, "key.categories.sbt") + ClientRegistry.registerKeyBinding(clearGemstones) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/STBKeyBindings.kt b/src/main/kotlin/com/github/itzilly/sbt/STBKeyBindings.kt deleted file mode 100644 index 12b1070..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/STBKeyBindings.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.github.itzilly.sbt - -import net.minecraft.client.settings.KeyBinding -import net.minecraftforge.fml.client.registry.ClientRegistry -import org.lwjgl.input.Keyboard - -object STBKeyBinds { - lateinit var addWaypoint: KeyBinding - lateinit var finishWaypoints: KeyBinding - lateinit var clearWaypoints: KeyBinding - lateinit var openRoutesGui: KeyBinding - lateinit var xrayChests: KeyBinding - - lateinit var xOffsetIncrease: KeyBinding - lateinit var xOffsetDecrease: KeyBinding - lateinit var zOffsetIncrease: KeyBinding - lateinit var zOffsetDecrease: KeyBinding - lateinit var showOffset: KeyBinding - - fun init() { - addWaypoint = KeyBinding("key.addWaypoint", Keyboard.KEY_ADD, "key.categories.sbt") - ClientRegistry.registerKeyBinding(addWaypoint) - - finishWaypoints = KeyBinding("key.finishWaypoints", Keyboard.KEY_P, "key.categories.sbt") - ClientRegistry.registerKeyBinding(finishWaypoints) - - clearWaypoints = KeyBinding("key.clearWaypoints", Keyboard.KEY_MINUS, "key.categories.sbt") - ClientRegistry.registerKeyBinding(clearWaypoints) - - 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) - - xOffsetIncrease = KeyBinding("key.xOffsetIncrease", Keyboard.KEY_RIGHT, "key.categories.sbt") -// ClientRegistry.registerKeyBinding(xOffsetIncrease) - - xOffsetDecrease = KeyBinding("key.xOffsetDecrease", Keyboard.KEY_LEFT, "key.categories.sbt") -// ClientRegistry.registerKeyBinding(xOffsetDecrease) - - zOffsetIncrease = KeyBinding("key.zOffsetIncrease", Keyboard.KEY_UP, "key.categories.sbt") -// ClientRegistry.registerKeyBinding(zOffsetIncrease) - - zOffsetDecrease = KeyBinding("key.zOffsetDecrease", Keyboard.KEY_DOWN, "key.categories.sbt") -// ClientRegistry.registerKeyBinding(zOffsetDecrease) - - showOffset = KeyBinding("key.showOffset", Keyboard.KEY_INSERT, "key.categories.sbt") -// ClientRegistry.registerKeyBinding(showOffset) - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt b/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt index 246f6b6..1f5a142 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt @@ -1,26 +1,14 @@ package com.github.itzilly.sbt -import com.github.itzilly.sbt.features.RouteBuilder -import com.github.itzilly.sbt.features.mining.lockedChestESP.LockedChestEsp.highlightChests -import com.github.itzilly.sbt.features.mining.routeMaker.* -import com.github.itzilly.sbt.features.mining.routeMaker.RouteMaker.markerList -import com.github.itzilly.sbt.renderer.RenderUtils -import com.google.gson.Gson +import com.github.itzilly.sbt.features.ChestEsp +import com.github.itzilly.sbt.features.GemstoneFinder +import com.github.itzilly.sbt.features.GrottoFinder +import com.github.itzilly.sbt.features.router.RouteBuilder +import com.github.itzilly.sbt.util.MessageScheduler import net.minecraft.client.Minecraft -import net.minecraft.util.AxisAlignedBB -import net.minecraft.util.ChatComponentText import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.FMLInitializationEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.InputEvent -import org.lwjgl.opengl.GL11 -import java.awt.Color -import java.awt.Toolkit -import java.awt.datatransfer.Clipboard -import java.awt.datatransfer.StringSelection -import kotlin.math.round - @Mod(modid = "sbt", useMetadata = true) class SkyBlockTweaks { @@ -34,98 +22,13 @@ class SkyBlockTweaks { @Mod.EventHandler fun init(event: FMLInitializationEvent) { -// try { -// val resource: net.minecraft.client.resources.IResource = Minecraft.getMinecraft().resourceManager -// .getResource(net.minecraft.util.ResourceLocation("test:test.txt")) -// org.apache.commons.io.IOUtils.copy(resource.inputStream, System.out) -// } catch (e: java.io.IOException) { -// throw java.lang.RuntimeException(e) -// } - - // STBKeyBinds.init() - -// MinecraftForge.EVENT_BUS.register(this) -// MinecraftForge.EVENT_BUS.register(KeyInputHandler()) -// MinecraftForge.EVENT_BUS.register(RouteMarkerRender) -// MinecraftForge.EVENT_BUS.register(LockedChestEsp) + STBKeyBinds.init() MinecraftForge.EVENT_BUS.register(RouteBuilder) + MinecraftForge.EVENT_BUS.register(InputHandler()) + MinecraftForge.EVENT_BUS.register(MessageScheduler) + MinecraftForge.EVENT_BUS.register(GrottoFinder) + MinecraftForge.EVENT_BUS.register(ChestEsp) + MinecraftForge.EVENT_BUS.register(GemstoneFinder) } -} - -class KeyInputHandler { - private val mc = Minecraft.getMinecraft() - - @SubscribeEvent - fun onKeyInput(event: InputEvent.KeyInputEvent?) { - if (STBKeyBinds.addWaypoint.isPressed) { - val x = round(mc.thePlayer.posX - 0.5).toInt() - val y = round(mc.thePlayer.posY).toInt() - val z = round(mc.thePlayer.posZ - 0.5).toInt() - - if (!isPointInRouteList(markerList, x, y, z)) { - val name = markerList.size + 1 - val point = RouteMarker(x, y, z, 0u, 1u, 0u, RouteOptions(name.toString())) - markerList.add(point) - mc.thePlayer.addChatMessage(ChatComponentText("Adding Point ($x, $y, $z) to route list")) - } else { - mc.thePlayer.addChatMessage(ChatComponentText("Point ($x, $y, $z) is already in the route list")) - } - - } else if (STBKeyBinds.finishWaypoints.isPressed) { - mc.thePlayer.addChatMessage(ChatComponentText("Finished route! Copied route to clipboard")) - val jsonString = Gson().toJson(markerList) - setClipboard(jsonString) - markerList.clear() - } else if (STBKeyBinds.clearWaypoints.isPressed) { - markerList.clear() - mc.thePlayer.addChatMessage(ChatComponentText("Reset current route")) - } else if (STBKeyBinds.openRoutesGui.isPressed) { - mc.displayGuiScreen(RouteGui()) - } else if (STBKeyBinds.xrayChests.isPressed) { - highlightChests() - } - } -} - - -fun setClipboard(s: String) { - val selection = StringSelection(s) - val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard - clipboard.setContents(selection, selection) -} - - -class BlockRenderer { - private var time = 0.0f - - fun update() { - // Increment the time variable for animation - time += 0.1f // Adjust the increment for desired speed - } - - fun renderRouteMarker(marker: RouteMarker) { - val box = AxisAlignedBB( - marker.x.toDouble(), - marker.y.toDouble(), - marker.z.toDouble(), - (marker.x + 1).toDouble(), - (marker.y + 1).toDouble(), - (marker.z + 1).toDouble() - ) - val startColor = Color(marker.r.toInt() and 0xFF, marker.g.toInt() and 0xFF, marker.b.toInt() and 0xFF, 255) - val endColor = Color( - 255 - (marker.r.toInt() and 0xFF), - 255 - (marker.g.toInt() and 0xFF), - 255 - (marker.b.toInt() and 0xFF), - 255 - ) - - RenderUtils.drawAnimatedBlockTop(box, startColor, endColor, time) - RenderUtils.drawAnimatedBlockBottom(box, startColor, endColor, time) - RenderUtils.drawAnimatedBlockNorth(box, startColor, endColor, time) - RenderUtils.drawAnimatedBlockEast(box, startColor, endColor, time) - RenderUtils.drawAnimatedBlockSouth(box, startColor, endColor, time) - RenderUtils.drawAnimatedBlockWest(box, startColor, endColor, time) - } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/ChestEsp.kt b/src/main/kotlin/com/github/itzilly/sbt/features/ChestEsp.kt new file mode 100644 index 0000000..b741790 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/ChestEsp.kt @@ -0,0 +1,173 @@ +package com.github.itzilly.sbt.features + +import com.github.itzilly.sbt.renderer.RenderUtils +import java.awt.Color +import com.github.itzilly.sbt.util.Chatterbox +import com.github.itzilly.sbt.util.DelayedFunction +import com.github.itzilly.sbt.util.SimpleChatMsg +import com.github.itzilly.sbt.util.Vecd3 +import net.minecraft.block.Block +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.init.Blocks +import net.minecraft.util.BlockPos +import net.minecraft.entity.Entity +import net.minecraft.util.AxisAlignedBB +import net.minecraft.util.MovingObjectPosition +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.event.entity.player.PlayerInteractEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.opengl.GL11 + + +data class ChestNode( + val x: Int, + val y: Int, + val z: Int, +) + +fun chestNodeExists(x: Int, y: Int, z: Int): Boolean { + return ChestEsp.chestList.any { it.x == x && it.y == y && it.z == z } +} +object ChestEsp { + var chestList: ArrayList = ArrayList() + + @SubscribeEvent + fun chatMessageEvent(event: ClientChatReceivedEvent) { + if (event.message.unformattedText == "You uncovered a treasure chest!") { + DelayedFunction({ highlightChests() }, 5) + } + } + + @SubscribeEvent + fun renderBlockOverlay(event: RenderWorldLastEvent) { + val player = Minecraft.getMinecraft().thePlayer + + for (chest: ChestNode in chestList) { + val pos = BlockPos(chest.x, chest.y, chest.z) + drawChestOutline(player, pos, event.partialTicks) + drawChestLine(pos, event.partialTicks) + } + } + + @SubscribeEvent + fun rightClickEvent(event: PlayerInteractEvent) { + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + val player = event.entityPlayer + val reachDistance = 5.0 + val eyePosition = player.getPositionEyes(1.0f) + val lookVec = player.getLook(1.0f) + val reachVec = eyePosition.addVector( + lookVec.xCoord * reachDistance, + lookVec.yCoord * reachDistance, + lookVec.zCoord * reachDistance + ) + val rayTraceResult = event.world.rayTraceBlocks(eyePosition, reachVec, false, false, false) + + if (rayTraceResult != null && rayTraceResult.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + val pos = rayTraceResult.blockPos + + val x = pos.x + val y = pos.y + val z = pos.z + + if (chestNodeExists(x, y, z)) { + chestList.removeIf { it.x == x && it.y == y && it.z == z } + } + + } + } + } + + 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 + +// Chatterbox.say(SimpleChatMsg("Searching for chests...").aqua()) + for (x in boundXMin.toInt()..boundXMax.toInt()) { + for (y in boundYMin.toInt()..boundYMax.toInt()) { + for (z in boundZMin.toInt()..boundZMax.toInt()) { + val block = world.getBlockState(BlockPos(x, y, z)).block + if (block == Blocks.chest || block == Blocks.trapped_chest || block == Blocks.ender_chest) { + val point = ChestNode(x, y, z) + if (!chestNodeExists(x, y, z)) { + chestList.add(point) + } + } + } + } + } +// Chatterbox.say(SimpleChatMsg("Done!").green()) + } + + + private fun drawChestOutline(entity: Entity, blockPos: BlockPos, partialTicks: Float) { + val padding: Double = 0.0020000000949949026 + + val entityX: Double = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks + val entityY: Double = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks + val entityZ: Double = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks + + val outlineStartColor = 0xFFFFFF + val outlineEndColor = 0xFFFFFF + + val world = Minecraft.getMinecraft().theWorld + val blockState = world.getBlockState(blockPos) + val block: Block = blockState.block + + // 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) + + GL11.glPushMatrix() + GlStateManager.disableTexture2D() + GlStateManager.depthMask(false) + GlStateManager.disableDepth() + GL11.glEnable(GL11.GL_LINE_SMOOTH) + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST) + GL11.glLineWidth(2.0f) + GL11.glShadeModel(GL11.GL_SMOOTH) + + RenderUtils.drawBlock(boundingBox.offset(-entityX, -entityY, -entityZ), outlineStartColor, outlineEndColor) + + GL11.glLineWidth(2.0f) + GL11.glDisable(GL11.GL_LINE_SMOOTH) + GlStateManager.enableDepth() + GlStateManager.depthMask(true) + GlStateManager.enableAlpha() + GlStateManager.enableTexture2D() + GL11.glPopMatrix() + } + + private fun drawChestLine(pos: BlockPos, partialTicks: Float) { + val render = Minecraft.getMinecraft().renderViewEntity + val rm = Minecraft.getMinecraft().renderManager + // TODO: Fix this not working with view bobbing enabled + val pos1 = Vecd3(rm.viewerPosX, rm.viewerPosY + render.eyeHeight, rm.viewerPosZ) + + val pos2 = Vecd3( + pos.x.toDouble() + 0.5, // Center of the block + pos.y.toDouble() + 0.5, // Center of the block + pos.z.toDouble() + 0.5 // Center of the block + ) + + val lineColor = Color(0xe310d5) + RenderUtils.drawLine(pos1, pos2, lineColor, 2, false, partialTicks) + } +} diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/GemstoneFinder.kt b/src/main/kotlin/com/github/itzilly/sbt/features/GemstoneFinder.kt new file mode 100644 index 0000000..097832f --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/GemstoneFinder.kt @@ -0,0 +1,108 @@ +package com.github.itzilly.sbt.features + +import com.github.itzilly.sbt.renderer.RenderFuncs +import net.minecraft.client.Minecraft +import net.minecraft.init.Blocks +import net.minecraft.util.BlockPos +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +enum class GemstoneColors(val color: Int) { + RUBY(0xFF5555), // Red + JADE(0x00AA00), // Lime + AMBER(0xFFAA00), // Orange + SAPPHIRE(0x55FFFF), // Light Blue + AMETHYST(0xAA00AA), // Purple + TOPAZ(0xFFFF55), // Yellow + JASPER(0xFF55FF) // Magenta +} + +object GemstoneFinder { + private var gemstoneList: ArrayList = ArrayList() + + fun clear() { + gemstoneList.clear() + } + + fun find() { + val playerPos = Minecraft.getMinecraft().thePlayer.position + + val minBounds = BlockPos( + playerPos.x - 32, + maxOf(playerPos.y - 32, 31), + playerPos.z - 32 + ) + + val maxBounds = BlockPos( + playerPos.x + 32, + minOf(playerPos.y + 32, 188), + playerPos.z + 32 + ) + val world = Minecraft.getMinecraft().thePlayer.worldObj + + for (chunkX in minBounds.x / 16..maxBounds.x / 16) { + for (chunkZ in minBounds.z / 16..maxBounds.z / 16) { + val chunk = world.getChunkFromChunkCoords(chunkX, chunkZ) + + // Iterate through the chunk's blocks within the world bounds + for (x in 0..15) { + for (y in minBounds.y..maxBounds.y) { + for (z in 0..15) { + val worldX = chunk.xPosition * 16 + x + val worldZ = chunk.zPosition * 16 + z + + if (worldX in minBounds.x..maxBounds.x && worldZ in minBounds.z..maxBounds.z) { + val blockPos = BlockPos(worldX, y, worldZ) + val blockState = chunk.getBlockState(blockPos) + val block = blockState.block + if (block == Blocks.air) { continue } + val meta = block.getMetaFromState(blockState) + + val gemstoneColor = when { + block === Blocks.stained_glass || block === Blocks.stained_glass_pane -> { + when (meta) { + 1 -> GemstoneColors.AMBER // Orange + 2 -> GemstoneColors.JASPER // Magenta + 3 -> GemstoneColors.SAPPHIRE // Light Blue + 4 -> GemstoneColors.TOPAZ // Yellow + 5 -> GemstoneColors.JADE // Lime + 14 -> GemstoneColors.RUBY // Red + 10 -> GemstoneColors.AMETHYST // Purple + + else -> null + } + } + else -> null + } + if (gemstoneColor != null && !gemstonesList(blockPos.x, blockPos.y, blockPos.z)) { + gemstoneList.add(GemstoneBlock(blockPos.x, blockPos.y, blockPos.z, gemstoneColor)) + } + } + } + } + } + } + } + } + + @SubscribeEvent + fun renderBlockOverlay(event: RenderWorldLastEvent) { + val player = Minecraft.getMinecraft().thePlayer + + for (gemstone: GemstoneBlock in gemstoneList) { + val pos = BlockPos(gemstone.x, gemstone.y, gemstone.z) + RenderFuncs.drawBlockOutline(player, pos, event.partialTicks, gemstone.color.color) + } + } + + data class GemstoneBlock( + val x: Int, + val y: Int, + val z: Int, + val color: GemstoneColors + ) + + fun gemstonesList(x: Int, y: Int, z: Int): Boolean { + return gemstoneList.any { it.x == x && it.y == y && it.z == z } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/GrottoFinder.kt b/src/main/kotlin/com/github/itzilly/sbt/features/GrottoFinder.kt new file mode 100644 index 0000000..88c0bed --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/GrottoFinder.kt @@ -0,0 +1,88 @@ +package com.github.itzilly.sbt.features + +import com.github.itzilly.sbt.renderer.RenderFuncs +import com.github.itzilly.sbt.util.Chatterbox +import com.github.itzilly.sbt.util.MessageScheduler +import com.github.itzilly.sbt.util.SimpleChatMsg +import net.minecraft.block.Block +import net.minecraft.block.state.IBlockState +import net.minecraft.client.Minecraft +import net.minecraft.client.network.NetHandlerPlayClient +import net.minecraft.init.Blocks +import net.minecraft.util.BlockPos +import net.minecraft.world.World +import net.minecraft.world.chunk.Chunk +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.event.world.ChunkEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + + +object GrottoFinder { + private val targetBlock: Block = Blocks.stained_glass + private val targetMeta: Int = 2 // Magenta stained glass + + private var magentaGlassList: ArrayList = ArrayList() + + private val minBounds = BlockPos(201, 30, 201) + private val maxBounds = BlockPos(824, 189, 824) + + var isEnabled: Boolean = true + + fun clear() { + magentaGlassList.clear() + } + + fun checkWorldForMagentaStainedGlass(world: World) { + for (chunkX in minBounds.x / 16..maxBounds.x / 16) { + for (chunkZ in minBounds.z / 16..maxBounds.z / 16) { + val chunk = world.getChunkFromChunkCoords(chunkX, chunkZ) + + // Iterate through the chunk's blocks within the world bounds + for (x in 0..15) { + for (y in minBounds.y..maxBounds.y) { + for (z in 0..15) { + val worldX = chunk.xPosition * 16 + x + val worldZ = chunk.zPosition * 16 + z + + // Ensure the block is within the specified bounds + if (worldX in minBounds.x..maxBounds.x && worldZ in minBounds.z..maxBounds.z) { + val blockPos = BlockPos(worldX, y, worldZ) + val blockState = chunk.getBlockState(blockPos) + val block = blockState.block + val meta = block.getMetaFromState(blockState) + + if (block === Blocks.stained_glass && meta == 2) { + if (!magentaNodeExists(blockPos.x, blockPos.y, blockPos.z)) { + magentaGlassList.add(ChestNode(blockPos.x, blockPos.y, blockPos.z)) + } + println("Found magenta stained glass at $blockPos") + val msg = SimpleChatMsg("Found magenta stained glass at $blockPos").light_purple() + Chatterbox.say(msg) + } + } + } + } + } + } + } + } + + @SubscribeEvent + fun renderBlockOverlay(event: RenderWorldLastEvent) { + val player = Minecraft.getMinecraft().thePlayer + + for (glass: ChestNode in magentaGlassList) { + val pos = BlockPos(glass.x, glass.y, glass.z) + RenderFuncs.drawBlockOutline(player, pos, event.partialTicks) + RenderFuncs.drawBlockLine(pos, event.partialTicks) + } + } + + private fun magentaNodeExists(x: Int, y: Int, z: Int): Boolean { + return magentaGlassList.any { it.x == x && it.y == y && it.z == z } + } + +} + + +// World Bounds 824, 189, 824 201, 30, 201 \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/LockedChestEsp.kt b/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/LockedChestEsp.kt deleted file mode 100644 index 1b9946a..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/LockedChestEsp.kt +++ /dev/null @@ -1,113 +0,0 @@ -package com.github.itzilly.sbt.features.mining.lockedChestESP - -import com.github.itzilly.sbt.features.NodeOptions -import com.github.itzilly.sbt.features.RouteBuilder -import com.github.itzilly.sbt.features.RouteNode -import com.github.itzilly.sbt.features.mining.routeMaker.RouteMaker -import com.github.itzilly.sbt.features.mining.routeMaker.RouteMarker -import com.github.itzilly.sbt.features.mining.routeMaker.RouteMarkerRender.renderPoint -import com.github.itzilly.sbt.features.mining.routeMaker.RouteOptions -import com.github.itzilly.sbt.util.DelayedFunction -import net.minecraft.client.Minecraft -import net.minecraft.init.Blocks -import net.minecraft.util.BlockPos -import net.minecraft.util.ChatComponentText -import net.minecraft.util.MovingObjectPosition -import net.minecraftforge.client.event.ClientChatReceivedEvent -import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.event.entity.player.PlayerInteractEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object LockedChestEsp { - var chestsList: ArrayList = ArrayList() - - @SubscribeEvent - fun chatMessageEvent(event: ClientChatReceivedEvent) { - if (event.message.unformattedText == "You uncovered a treasure chest!") { - DelayedFunction({ highlightChests() }, 5) - } - } - - @SubscribeEvent - fun renderBlockOverlay(event: RenderWorldLastEvent) { - val player = Minecraft.getMinecraft().thePlayer - - for (marker: RouteMarker in RouteMaker.markerList) { - val pos = BlockPos(marker.x, marker.y, marker.z) - renderPoint(player, pos, event.partialTicks) - } - } - - @SubscribeEvent - fun rightClickEvent(event: PlayerInteractEvent) { - println("Event, $event") - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - val player = event.entityPlayer - val reachDistance = 5.0 - val eyePosition = player.getPositionEyes(1.0f) - val lookVec = player.getLook(1.0f) - val reachVec = eyePosition.addVector( - lookVec.xCoord * reachDistance, - lookVec.yCoord * reachDistance, - lookVec.zCoord * reachDistance - ) - val rayTraceResult = event.world.rayTraceBlocks(eyePosition, reachVec, false, false, false) - - if (rayTraceResult != null && rayTraceResult.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - val pos = rayTraceResult.blockPos - - val x = pos.x - val y = pos.y - val z = pos.z - - if (nodeExists(x, y, z)) { - chestsList.removeIf { it.x == x && it.y == y && it.z == z } - } - - } - } - } - - fun nodeExists(x: Int, y: Int, z: Int): Boolean { - return chestsList.any { it.x == x && it.y == y && it.z == z } - } - - 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...")) - for (x in boundXMin.toInt()..boundXMax.toInt()) { - for (y in boundYMin.toInt()..boundYMax.toInt()) { - for (z in boundZMin.toInt()..boundZMax.toInt()) { - val block = world.getBlockState(BlockPos(x, y, z)).block - if (block == Blocks.chest || block == Blocks.trapped_chest || block == Blocks.ender_chest) { - val point = RouteNode(x, y, z, 0u, 0u, 1u, NodeOptions("Located point")) - chestsList.add(point) - } - } - } - } - Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("Done!")) - -// SkyBlockTweaks.routeList.add(maxMarker) -// SkyBlockTweaks.routeList.add(minMarker) - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/GuiStuff.kt b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/GuiStuff.kt deleted file mode 100644 index 48f998a..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/GuiStuff.kt +++ /dev/null @@ -1,83 +0,0 @@ -package com.github.itzilly.sbt.features.mining.routeMaker - -import com.github.itzilly.sbt.features.mining.routeMaker.RouteMaker.markerList -import net.minecraft.client.Minecraft -import net.minecraft.client.gui.GuiButton -import net.minecraft.client.gui.GuiScreen -import net.minecraft.client.gui.GuiTextField -import net.minecraft.client.renderer.GlStateManager -import java.awt.Color - - -class RouteMarkerButton(buttonId: Int, x: Int, y: Int, widthIn: Int, heightIn: Int, buttonText: String?) : - GuiButton(buttonId, x, y, widthIn, heightIn, buttonText) { - constructor(buttonId: Int, x: Int, y: Int, buttonText: String?) : this(buttonId, x, y, 200, 20, buttonText) - - override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) { - if (visible) { - val fontrenderer = mc.fontRendererObj - //mc.getTextureManager().bindTexture(buttonTextures); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f) - hovered = - mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height - //int i = this.getHoverState(this.hovered); - drawRect( - xPosition, yPosition, xPosition + width, yPosition + height, - if (hovered) Color(255, 255, 255, 80).rgb else Color(0, 0, 0, 80).rgb - ) - //this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height); - //this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); - mouseDragged(mc, mouseX, mouseY) - var j = 14737632 - if (packedFGColour != 0) { - j = packedFGColour - } else if (!enabled) { - j = 10526880 - } else if (hovered) { - j = 16777120 - } - drawCenteredString( - fontrenderer, - displayString, xPosition + width / 2, yPosition + (height - 8) / 2, j - ) - } - } -} - -class RouteGui : GuiScreen() { - private val id: Int = 0 - - override fun initGui() { - super.initGui() - buttonList.clear() - - populateRouteList() - 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() - } - } - - override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { - this.drawDefaultBackground() - super.drawScreen(mouseX, mouseY, partialTicks) - } - - private fun populateRouteList() { - for ((buttonId, m: RouteMarker) in markerList.withIndex()) { - 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") - buttonList.add(removeButton) - } - } - -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMaker.kt b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMaker.kt deleted file mode 100644 index 575cb1c..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMaker.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.itzilly.sbt.features.mining.routeMaker - -object RouteMaker { - var markerList: ArrayList = ArrayList() -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarkerRender.kt b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarkerRender.kt deleted file mode 100644 index e47a582..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarkerRender.kt +++ /dev/null @@ -1,85 +0,0 @@ -package com.github.itzilly.sbt.features.mining.routeMaker - -import java.awt.Color -import org.lwjgl.opengl.GL11 -import net.minecraft.block.Block -import net.minecraft.util.BlockPos -import net.minecraft.entity.Entity -import net.minecraft.client.Minecraft -import net.minecraft.util.AxisAlignedBB -import com.github.itzilly.sbt.util.Vecd3 -import com.github.itzilly.sbt.renderer.RenderUtils -import net.minecraft.client.renderer.GlStateManager -import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object RouteMarkerRender { - @SubscribeEvent - fun renderBlockOverlay(event: RenderWorldLastEvent) { - val player = Minecraft.getMinecraft().thePlayer - - for (marker: RouteMarker in RouteMaker.markerList) { - val pos = BlockPos(marker.x, marker.y, marker.z) - renderPoint(player, pos, event.partialTicks) - renderLine(pos, event.partialTicks) - } - } - - fun renderPoint(entity: Entity, blockPos: BlockPos, partialTicks: Float) { - val padding: Double = 0.0020000000949949026 - - val entityX: Double = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks - val entityY: Double = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks - val entityZ: Double = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks - - val outlineStartColor = 0xFFFFFF - val outlineEndColor = 0xFFFFFF - - val world = Minecraft.getMinecraft().theWorld - val blockState = world.getBlockState(blockPos) - val block: Block = blockState.block - - // 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) - - GL11.glPushMatrix() - GlStateManager.disableTexture2D() - GlStateManager.depthMask(false) - GlStateManager.disableDepth() - GL11.glEnable(GL11.GL_LINE_SMOOTH) - GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST) - GL11.glLineWidth(2.0f) - GL11.glShadeModel(GL11.GL_SMOOTH) - - RenderUtils.drawBlock(boundingBox.offset(-entityX, -entityY, -entityZ), outlineStartColor, outlineEndColor) - - GL11.glLineWidth(2.0f) - GL11.glDisable(GL11.GL_LINE_SMOOTH) - GlStateManager.enableDepth() - GlStateManager.depthMask(true) - GlStateManager.enableAlpha() - GlStateManager.enableTexture2D() - GL11.glPopMatrix() - } - - private fun renderLine(pos: BlockPos, partialTicks: Float) { - val render = Minecraft.getMinecraft().renderViewEntity - val rm = Minecraft.getMinecraft().renderManager - // TODO: Fix this not working with view bobbing enabled - val pos1 = Vecd3(rm.viewerPosX, rm.viewerPosY + render.eyeHeight, rm.viewerPosZ) - - val pos2 = Vecd3( - pos.x.toDouble() + 0.5, // Center of the block - pos.y.toDouble() + 0.5, // Center of the block - pos.z.toDouble() + 0.5 // Center of the block - ) - - val lineColor = Color(0xe310d5) - RenderUtils.drawLine(pos1, pos2, lineColor, 2, false, partialTicks) - } - -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/router/RootMarker.kt b/src/main/kotlin/com/github/itzilly/sbt/features/router/RootMarker.kt new file mode 100644 index 0000000..bd45a28 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/router/RootMarker.kt @@ -0,0 +1 @@ +package com.github.itzilly.sbt.features.router diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/RouteBuilder.kt b/src/main/kotlin/com/github/itzilly/sbt/features/router/RouteBuilder.kt similarity index 76% rename from src/main/kotlin/com/github/itzilly/sbt/features/RouteBuilder.kt rename to src/main/kotlin/com/github/itzilly/sbt/features/router/RouteBuilder.kt index cbd6aec..06f5a7b 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/features/RouteBuilder.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/features/router/RouteBuilder.kt @@ -1,17 +1,25 @@ -package com.github.itzilly.sbt.features +package com.github.itzilly.sbt.features.router + + +import com.github.itzilly.sbt.renderer.RenderFuncs +import java.awt.datatransfer.Clipboard +import java.awt.datatransfer.StringSelection -import com.github.itzilly.sbt.setClipboard import com.github.itzilly.sbt.util.Chatterbox import com.github.itzilly.sbt.util.SimpleChatMsg import com.google.gson.Gson import net.minecraft.client.Minecraft import net.minecraft.client.settings.KeyBinding +import net.minecraft.util.BlockPos +import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.client.registry.ClientRegistry import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Keyboard +import java.awt.Toolkit import kotlin.math.round + object RouteBuilder { var addNodeKeybind: KeyBinding var deleteLastNodeKeybind: KeyBinding @@ -37,7 +45,7 @@ object RouteBuilder { if (addNodeKeybind.isPressed) { val mc = Minecraft.getMinecraft() val x = round(mc.thePlayer.posX - 0.5).toInt() - val y = round(mc.thePlayer.posY).toInt() + val y = round(mc.thePlayer.posY).toInt() - 1 val z = round(mc.thePlayer.posZ - 0.5).toInt() if (nodeExists(x, y, z)) { @@ -72,6 +80,17 @@ object RouteBuilder { } } + @SubscribeEvent + fun renderBlockOverlay(event: RenderWorldLastEvent) { + val player = Minecraft.getMinecraft().thePlayer + + for (marker: RouteNode in nodes) { + val pos = BlockPos(marker.x, marker.y, marker.z) + RenderFuncs.drawBlockOutline(player, pos, event.partialTicks) + RenderFuncs.drawBlockLine(pos, event.partialTicks) + } + } + fun addNode(x: Int, y: Int, z: Int) { nodes.add(RouteNode(x, y, z, 0u, 1u, 0u, NodeOptions("${nodes.size + 1}"))) } @@ -79,6 +98,12 @@ object RouteBuilder { fun addNode(x: Int, y: Int, z: Int, r: UByte, g: UByte, b: UByte) { nodes.add(RouteNode(x, y, z, r, g, b, NodeOptions("${nodes.size + 1}"))) } + + fun setClipboard(s: String) { + val selection = StringSelection(s) + val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard + clipboard.setContents(selection, selection) + } } data class RouteNode( diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarker.kt b/src/main/kotlin/com/github/itzilly/sbt/features/router/RouteMaker.kt similarity index 74% rename from src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarker.kt rename to src/main/kotlin/com/github/itzilly/sbt/features/router/RouteMaker.kt index 9697cde..bf9f6d4 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarker.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/features/router/RouteMaker.kt @@ -1,5 +1,8 @@ -package com.github.itzilly.sbt.features.mining.routeMaker +package com.github.itzilly.sbt.features.router +object RouteMaker { + var markerList: ArrayList = ArrayList() +} data class RouteMarker( val x: Int, diff --git a/src/main/kotlin/com/github/itzilly/sbt/mixin/MixinGuiMainMenu.java b/src/main/kotlin/com/github/itzilly/sbt/mixin/MixinGuiMainMenu.java index 78a39ba..0b7bca2 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/mixin/MixinGuiMainMenu.java +++ b/src/main/kotlin/com/github/itzilly/sbt/mixin/MixinGuiMainMenu.java @@ -11,6 +11,6 @@ public class MixinGuiMainMenu { @Inject(method = "initGui", at = @At("HEAD")) public void onInitGui(CallbackInfo ci) { - // System.out.println("Hello from Main Menu!"); + System.out.println("Hello from Main Menu!"); } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerAccessor.kt b/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerAccessor.kt deleted file mode 100644 index f2a43e5..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerAccessor.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.github.itzilly.sbt.mixin; - -interface RenderManagerAccessor { - var renderPosX: Double - var renderPosY: Double - var renderPosZ: Double -} diff --git a/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerMixin.kt b/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerMixin.kt deleted file mode 100644 index da54dc1..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerMixin.kt +++ /dev/null @@ -1,22 +0,0 @@ -import com.github.itzilly.sbt.mixin.RenderManagerAccessor -import org.spongepowered.asm.mixin.Mixin -import org.spongepowered.asm.mixin.gen.Accessor -import net.minecraft.client.renderer.entity.RenderManager - -@Mixin(RenderManager::class) -abstract class RenderManagerMixin : RenderManagerAccessor { - @get:Accessor("renderPosX") - override var renderPosX: Double - get() = throw IllegalStateException("Accessor mixin failed") - set(value) = throw IllegalStateException("Accessor mixin failed") - - @get:Accessor("renderPosY") - override var renderPosY: Double - get() = throw IllegalStateException("Accessor mixin failed") - set(value) = throw IllegalStateException("Accessor mixin failed") - - @get:Accessor("renderPosZ") - override var renderPosZ: Double - get() = throw IllegalStateException("Accessor mixin failed") - set(value) = throw IllegalStateException("Accessor mixin failed") -} diff --git a/src/main/kotlin/com/github/itzilly/sbt/mycrap.kt b/src/main/kotlin/com/github/itzilly/sbt/mycrap.kt deleted file mode 100644 index 2b041ac..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/mycrap.kt +++ /dev/null @@ -1,95 +0,0 @@ -package com.github.itzilly.sbt - -import com.github.itzilly.sbt.renderer.RenderUtils -import net.minecraft.client.Minecraft -import net.minecraft.client.renderer.GlStateManager -import net.minecraft.util.AxisAlignedBB -import net.minecraft.util.ChatComponentText -import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.InputEvent -import org.lwjgl.opengl.GL11 -import kotlin.math.round - -object MyCrap { - var xOffset: Double = 0.0 - var zOffset: Double = 0.0 - - @SubscribeEvent - fun onKeyInput(event: InputEvent.KeyInputEvent) { - if (STBKeyBinds.xOffsetIncrease.isPressed) { - xOffset += 0.5 - Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("X Offset: $xOffset")) - } - - if (STBKeyBinds.xOffsetDecrease.isPressed) { - xOffset -= 0.5 - Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("X Offset: $xOffset")) - } - - if (STBKeyBinds.zOffsetIncrease.isPressed) { - zOffset += 0.5 - Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("Y Offset: $zOffset")) - } - - if (STBKeyBinds.zOffsetDecrease.isPressed) { - zOffset -= 0.5 - Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("Y Offset: $zOffset")) - } - - if (STBKeyBinds.showOffset.isPressed) { - Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("X Offset: $xOffset")) - Minecraft.getMinecraft().thePlayer.addChatMessage(ChatComponentText("Y Offset: $zOffset")) - } - - - } - - @SubscribeEvent - fun highlightBlockToAdd(event: RenderWorldLastEvent) { - val mc = Minecraft.getMinecraft() - val player = mc.thePlayer - val partialTicks = event.partialTicks - - // Get the rounded block position - val x = round(mc.thePlayer.posX - 0.5).toInt() - val y = round(mc.thePlayer.posY).toInt() - val z = round(mc.thePlayer.posZ - 0.5).toInt() - - val padding = 0.0020000000949949026 - - // Interpolate entity position for smooth rendering - val entityX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks - val entityY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks - val entityZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks - - val outlineStartColor = 0xFFFFFF - val outlineEndColor = 0xFFFFFF - - // Create a default bounding box for the air block - val boundingBox = AxisAlignedBB( - x.toDouble(), y.toDouble(), z.toDouble(), - x + 1.0, y + 1.0, z + 1.0 - ).expand(padding, padding, padding) - - GL11.glPushMatrix() - GlStateManager.disableTexture2D() - GlStateManager.depthMask(false) - GlStateManager.disableDepth() - GL11.glEnable(GL11.GL_LINE_SMOOTH) - GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST) - GL11.glLineWidth(2.0f) - GL11.glShadeModel(GL11.GL_SMOOTH) - - // Draw the block with the specified colors - RenderUtils.drawBlock(boundingBox.offset(-entityX, -entityY, -entityZ), outlineStartColor, outlineEndColor) - - GL11.glLineWidth(2.0f) - GL11.glDisable(GL11.GL_LINE_SMOOTH) - GlStateManager.enableDepth() - GlStateManager.depthMask(true) - GlStateManager.enableAlpha() - GlStateManager.enableTexture2D() - GL11.glPopMatrix() - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/ChestESPRender.kt b/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderFuncs.kt similarity index 54% rename from src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/ChestESPRender.kt rename to src/main/kotlin/com/github/itzilly/sbt/renderer/RenderFuncs.kt index b0612de..8c08aed 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/ChestESPRender.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderFuncs.kt @@ -1,9 +1,5 @@ -package com.github.itzilly.sbt.features.mining.lockedChestESP +package com.github.itzilly.sbt.renderer -import com.github.itzilly.sbt.features.RouteNode -import com.github.itzilly.sbt.features.mining.routeMaker.RouteMaker -import com.github.itzilly.sbt.features.mining.routeMaker.RouteMarker -import com.github.itzilly.sbt.renderer.RenderUtils import com.github.itzilly.sbt.util.Vecd3 import net.minecraft.block.Block import net.minecraft.client.Minecraft @@ -11,25 +7,60 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.Entity import net.minecraft.util.AxisAlignedBB import net.minecraft.util.BlockPos -import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.opengl.GL11 import java.awt.Color +object RenderFuncs { -object ChestESPRender { - @SubscribeEvent - fun renderBlockOverlay(event: RenderWorldLastEvent) { - val player = Minecraft.getMinecraft().thePlayer + fun drawBlockOutline(entity: Entity, blockPos: BlockPos, partialTicks: Float, outlineColor: Int) { + val padding = 0.0020000000949949026 - for (marker: RouteNode in LockedChestEsp.chestsList) { - val pos = BlockPos(marker.x, marker.y, marker.z) - renderPoint(player, pos, event.partialTicks) - renderLine(pos, event.partialTicks) - } + val entityX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks + val entityY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks + val entityZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks + + val world = Minecraft.getMinecraft().theWorld + val blockState = world.getBlockState(blockPos) + val block = blockState.block + + val boundingBox = 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) + + // Convert integer color to r, g, b, a values + val r = (outlineColor shr 16 and 0xFF) / 255.0f + val g = (outlineColor shr 8 and 0xFF) / 255.0f + val b = (outlineColor and 0xFF) / 255.0f + val a = (outlineColor shr 24 and 0xFF) / 255.0f + + GL11.glPushMatrix() + GlStateManager.disableTexture2D() + GlStateManager.depthMask(false) + GlStateManager.disableDepth() + GL11.glEnable(GL11.GL_BLEND) + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) + GL11.glEnable(GL11.GL_LINE_SMOOTH) + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST) + GL11.glLineWidth(2.0f) + + // Set the color with alpha + GL11.glColor4f(r, g, b, a) + + // Draw the outline using the bounding box + RenderUtils.drawBlock(boundingBox.offset(-entityX, -entityY, -entityZ), outlineColor, outlineColor) + + GL11.glDisable(GL11.GL_LINE_SMOOTH) + GL11.glDisable(GL11.GL_BLEND) + GlStateManager.enableDepth() + GlStateManager.depthMask(true) + GlStateManager.enableAlpha() + GlStateManager.enableTexture2D() + GL11.glPopMatrix() } - fun renderPoint(entity: Entity, blockPos: BlockPos, partialTicks: Float) { + fun drawBlockOutline(entity: Entity, blockPos: BlockPos, partialTicks: Float) { val padding: Double = 0.0020000000949949026 val entityX: Double = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks @@ -70,7 +101,7 @@ object ChestESPRender { GL11.glPopMatrix() } - private fun renderLine(pos: BlockPos, partialTicks: Float) { + fun drawBlockLine(pos: BlockPos, partialTicks: Float) { val render = Minecraft.getMinecraft().renderViewEntity val rm = Minecraft.getMinecraft().renderManager // TODO: Fix this not working with view bobbing enabled @@ -85,5 +116,4 @@ object ChestESPRender { val lineColor = Color(0xe310d5) RenderUtils.drawLine(pos1, pos2, lineColor, 2, false, partialTicks) } - } \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderUtils.kt b/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderUtils.kt index 5dab7df..410f13f 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderUtils.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderUtils.kt @@ -1,5 +1,6 @@ package com.github.itzilly.sbt.renderer + import com.github.itzilly.sbt.util.Vecd3 import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager diff --git a/src/main/kotlin/com/github/itzilly/sbt/util/Chatterbox.kt b/src/main/kotlin/com/github/itzilly/sbt/util/Chatterbox.kt index 4591dbb..9ca202c 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/util/Chatterbox.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/util/Chatterbox.kt @@ -1,6 +1,7 @@ package com.github.itzilly.sbt.util import net.minecraft.client.Minecraft +import net.minecraft.entity.player.EntityPlayer import net.minecraft.util.ChatComponentText import net.minecraft.util.ChatStyle import net.minecraft.util.EnumChatFormatting @@ -33,4 +34,8 @@ object Chatterbox { fun say(component: IChatComponent) { player.addChatMessage(copy(prefixComponent).appendSibling(copy(component))) } + + fun say(player: EntityPlayer, component: IChatComponent) { + player.addChatMessage(copy(prefixComponent).appendSibling(copy(component))) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/util/MessageScheduler.kt b/src/main/kotlin/com/github/itzilly/sbt/util/MessageScheduler.kt new file mode 100644 index 0000000..ce995b8 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/util/MessageScheduler.kt @@ -0,0 +1,22 @@ +package com.github.itzilly.sbt.util + +import net.minecraft.util.IChatComponent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent + +object MessageScheduler { + private val components: MutableList = mutableListOf() + + @SubscribeEvent + fun onPlayerLoggedIn(event: PlayerLoggedInEvent) { + val player = event.player + for (component in components) { + Chatterbox.say(player, component) + } + components.clear() // Clear the list after sending the messages + } + + fun sayWhenReady(component: IChatComponent) { + components.add(component) + } +} \ No newline at end of file