ChestESP, Route Builder, Chatterbox, Gemstone Finder, Grotto Finder

This commit is contained in:
illyum 2024-08-12 16:21:07 -06:00
parent 6d9b943e2c
commit fbaab2536f
24 changed files with 576 additions and 620 deletions

View File

@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g
baseGroup = com.github.itzilly.sbt baseGroup = com.github.itzilly.sbt
mcVersion = 1.8.9 mcVersion = 1.8.9
modid = sbt modid = sbt
version = 1.0.1 version = 1.4.0

View File

@ -1,24 +0,0 @@
package com.github.itzilly.sbt
import net.minecraft.client.renderer.GlStateManager
import java.util.*
//class HudText(var textLines: Array<String>, 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()
// }
//}

View File

@ -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()
}
}
}

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -1,26 +1,14 @@
package com.github.itzilly.sbt package com.github.itzilly.sbt
import com.github.itzilly.sbt.features.RouteBuilder import com.github.itzilly.sbt.features.ChestEsp
import com.github.itzilly.sbt.features.mining.lockedChestESP.LockedChestEsp.highlightChests import com.github.itzilly.sbt.features.GemstoneFinder
import com.github.itzilly.sbt.features.mining.routeMaker.* import com.github.itzilly.sbt.features.GrottoFinder
import com.github.itzilly.sbt.features.mining.routeMaker.RouteMaker.markerList import com.github.itzilly.sbt.features.router.RouteBuilder
import com.github.itzilly.sbt.renderer.RenderUtils import com.github.itzilly.sbt.util.MessageScheduler
import com.google.gson.Gson
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.ChatComponentText
import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent 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) @Mod(modid = "sbt", useMetadata = true)
class SkyBlockTweaks { class SkyBlockTweaks {
@ -34,98 +22,13 @@ class SkyBlockTweaks {
@Mod.EventHandler @Mod.EventHandler
fun init(event: FMLInitializationEvent) { fun init(event: FMLInitializationEvent) {
// try { STBKeyBinds.init()
// 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)
MinecraftForge.EVENT_BUS.register(RouteBuilder) 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)
}
}

View File

@ -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<ChestNode> = 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)
}
}

View File

@ -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<GemstoneBlock> = 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 }
}
}

View File

@ -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<ChestNode> = 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

View File

@ -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<RouteNode> = 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)
}
}

View File

@ -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)
}
}
}

View File

@ -1,5 +0,0 @@
package com.github.itzilly.sbt.features.mining.routeMaker
object RouteMaker {
var markerList: ArrayList<RouteMarker> = ArrayList()
}

View File

@ -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)
}
}

View File

@ -0,0 +1 @@
package com.github.itzilly.sbt.features.router

View File

@ -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.Chatterbox
import com.github.itzilly.sbt.util.SimpleChatMsg import com.github.itzilly.sbt.util.SimpleChatMsg
import com.google.gson.Gson import com.google.gson.Gson
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraft.client.settings.KeyBinding 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.client.registry.ClientRegistry
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent import net.minecraftforge.fml.common.gameevent.InputEvent
import org.lwjgl.input.Keyboard import org.lwjgl.input.Keyboard
import java.awt.Toolkit
import kotlin.math.round import kotlin.math.round
object RouteBuilder { object RouteBuilder {
var addNodeKeybind: KeyBinding var addNodeKeybind: KeyBinding
var deleteLastNodeKeybind: KeyBinding var deleteLastNodeKeybind: KeyBinding
@ -37,7 +45,7 @@ object RouteBuilder {
if (addNodeKeybind.isPressed) { if (addNodeKeybind.isPressed) {
val mc = Minecraft.getMinecraft() val mc = Minecraft.getMinecraft()
val x = round(mc.thePlayer.posX - 0.5).toInt() 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() val z = round(mc.thePlayer.posZ - 0.5).toInt()
if (nodeExists(x, y, z)) { 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) { fun addNode(x: Int, y: Int, z: Int) {
nodes.add(RouteNode(x, y, z, 0u, 1u, 0u, NodeOptions("${nodes.size + 1}"))) 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) { 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}"))) 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( data class RouteNode(

View File

@ -1,5 +1,8 @@
package com.github.itzilly.sbt.features.mining.routeMaker package com.github.itzilly.sbt.features.router
object RouteMaker {
var markerList: ArrayList<RouteMarker> = ArrayList()
}
data class RouteMarker( data class RouteMarker(
val x: Int, val x: Int,

View File

@ -11,6 +11,6 @@ public class MixinGuiMainMenu {
@Inject(method = "initGui", at = @At("HEAD")) @Inject(method = "initGui", at = @At("HEAD"))
public void onInitGui(CallbackInfo ci) { public void onInitGui(CallbackInfo ci) {
// System.out.println("Hello from Main Menu!"); System.out.println("Hello from Main Menu!");
} }
} }

View File

@ -1,7 +0,0 @@
package com.github.itzilly.sbt.mixin;
interface RenderManagerAccessor {
var renderPosX: Double
var renderPosY: Double
var renderPosZ: Double
}

View File

@ -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")
}

View File

@ -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()
}
}

View File

@ -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 com.github.itzilly.sbt.util.Vecd3
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
@ -11,25 +7,60 @@ import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.Entity import net.minecraft.entity.Entity
import net.minecraft.util.AxisAlignedBB import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.BlockPos import net.minecraft.util.BlockPos
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import java.awt.Color import java.awt.Color
object RenderFuncs {
object ChestESPRender { fun drawBlockOutline(entity: Entity, blockPos: BlockPos, partialTicks: Float, outlineColor: Int) {
@SubscribeEvent val padding = 0.0020000000949949026
fun renderBlockOverlay(event: RenderWorldLastEvent) {
val player = Minecraft.getMinecraft().thePlayer
for (marker: RouteNode in LockedChestEsp.chestsList) { val entityX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks
val pos = BlockPos(marker.x, marker.y, marker.z) val entityY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks
renderPoint(player, pos, event.partialTicks) val entityZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks
renderLine(pos, event.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 padding: Double = 0.0020000000949949026
val entityX: Double = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks val entityX: Double = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks
@ -70,7 +101,7 @@ object ChestESPRender {
GL11.glPopMatrix() GL11.glPopMatrix()
} }
private fun renderLine(pos: BlockPos, partialTicks: Float) { fun drawBlockLine(pos: BlockPos, partialTicks: Float) {
val render = Minecraft.getMinecraft().renderViewEntity val render = Minecraft.getMinecraft().renderViewEntity
val rm = Minecraft.getMinecraft().renderManager val rm = Minecraft.getMinecraft().renderManager
// TODO: Fix this not working with view bobbing enabled // TODO: Fix this not working with view bobbing enabled
@ -85,5 +116,4 @@ object ChestESPRender {
val lineColor = Color(0xe310d5) val lineColor = Color(0xe310d5)
RenderUtils.drawLine(pos1, pos2, lineColor, 2, false, partialTicks) RenderUtils.drawLine(pos1, pos2, lineColor, 2, false, partialTicks)
} }
} }

View File

@ -1,5 +1,6 @@
package com.github.itzilly.sbt.renderer package com.github.itzilly.sbt.renderer
import com.github.itzilly.sbt.util.Vecd3 import com.github.itzilly.sbt.util.Vecd3
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.GlStateManager

View File

@ -1,6 +1,7 @@
package com.github.itzilly.sbt.util package com.github.itzilly.sbt.util
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.util.ChatComponentText import net.minecraft.util.ChatComponentText
import net.minecraft.util.ChatStyle import net.minecraft.util.ChatStyle
import net.minecraft.util.EnumChatFormatting import net.minecraft.util.EnumChatFormatting
@ -33,4 +34,8 @@ object Chatterbox {
fun say(component: IChatComponent) { fun say(component: IChatComponent) {
player.addChatMessage(copy(prefixComponent).appendSibling(copy(component))) player.addChatMessage(copy(prefixComponent).appendSibling(copy(component)))
} }
fun say(player: EntityPlayer, component: IChatComponent) {
player.addChatMessage(copy(prefixComponent).appendSibling(copy(component)))
}
} }

View File

@ -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<IChatComponent> = 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)
}
}