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
This commit is contained in:
parent
f79942969a
commit
3f5e7acc0f
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
key.categories.sbt=SkyBlock Tweaks
|
||||
key.addWaypoint=Add Route Point
|
||||
key.finishWaypoints=Finish Route
|
||||
key.clearWaypoints=Clear Route Points
|
||||
key.clearWaypoints=Clear Route Points
|
||||
key.openRoutesGui=Open Route GUI
|
||||
key.xrayToggle=Toggle ChestESP
|
Loading…
x
Reference in New Issue
Block a user