(FEAT): Add configuration and commands to gemstone finder and powder chestESP

This commit is contained in:
illyum 2024-08-19 18:59:52 -06:00
parent fbaab2536f
commit 5970d2d427
9 changed files with 214 additions and 14 deletions

View File

@ -1,3 +1,9 @@
# SkyBlockTweaks
My QOL mod for Hypixel Skyblock
My QOL mod for Hypixel Skyblock
## Includes:
- Grotto Finder
- Gemstone Finder
- Powder ChestESP
- Route Builder

View File

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

View File

@ -0,0 +1,86 @@
package com.github.itzilly.sbt
import com.github.itzilly.sbt.features.ChestEsp
import com.github.itzilly.sbt.features.GemstoneFinder
import net.minecraft.command.CommandBase
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
import net.minecraft.util.ChatComponentText
import net.minecraftforge.common.config.Configuration.*
class SBTCommand : CommandBase() {
override fun getCommandName(): String {
return "sbt"
}
override fun getCommandUsage(sender: ICommandSender): String {
return "/sbt <powderchests/gemstonesearchradius> [enable/disable/radius]"
}
override fun getRequiredPermissionLevel(): Int {
return 0
}
@Throws(CommandException::class)
override fun processCommand(sender: ICommandSender, args: Array<String>) {
if (args.isEmpty()) {
sender.addChatMessage(ChatComponentText("Invalid command. Usage: /sbt <powderchests/gemstonesearchradius> [enable/disable/radius]"))
return
}
when (args[0].lowercase()) {
"powderchests" -> {
if (args.size < 2) {
sender.addChatMessage(ChatComponentText("Usage: /sbt powderchests <enable/disable>"))
return
}
when (args[1].lowercase()) {
"enable" -> {
ChestEsp.enabled = true
SkyBlockTweaks.config.getCategory(CATEGORY_GENERAL)?.get("powderchestenable")?.set(true)
SkyBlockTweaks.config.save()
sender.addChatMessage(ChatComponentText("Powder ChestESP enabled."))
}
"disable" -> {
ChestEsp.enabled = false
SkyBlockTweaks.config.getCategory(CATEGORY_GENERAL)?.get("powderchestenable")?.set(false)
SkyBlockTweaks.config.save()
sender.addChatMessage(ChatComponentText("Powder ChestESP disabled."))
}
else -> {
sender.addChatMessage(ChatComponentText("Invalid option. Usage: /sbt powderchests <enable/disable>"))
}
}
}
"gemstonesearchradius" -> {
if (args.size < 2) {
sender.addChatMessage(ChatComponentText("Usage: /sbt gemstonesearchradius <radius>"))
return
}
try {
val radius = args[1].toInt()
if (radius < 0) {
sender.addChatMessage(ChatComponentText("Radius must be a positive integer."))
return
}
SkyBlockTweaks.config.getCategory(CATEGORY_GENERAL)?.get("gemstonesearchradius")?.set(radius)
SkyBlockTweaks.config.save()
GemstoneFinder.radius = radius
sender.addChatMessage(ChatComponentText("Gemstone search radius set to $radius."))
} catch (e: NumberFormatException) {
sender.addChatMessage(ChatComponentText("Invalid radius. Please provide a positive integer."))
}
}
else -> {
sender.addChatMessage(ChatComponentText("Invalid command. Usage: /sbt <powderchests/gemstonesearchradius> [enable/disable/radius]"))
}
}
}
}

View File

@ -5,12 +5,15 @@ 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.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.config.Configuration
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import java.io.File
@Mod(modid = "sbt", useMetadata = true)
@Mod(modid = "sbt", useMetadata = true, clientSideOnly = true)
class SkyBlockTweaks {
init {
INSTANCE = this
@ -18,6 +21,14 @@ class SkyBlockTweaks {
companion object {
lateinit var INSTANCE: SkyBlockTweaks
lateinit var config: Configuration
}
@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) {
val directory = event.modConfigurationDirectory
config = Configuration(File(directory.path, "sbt.cfg"))
loadConfig()
}
@Mod.EventHandler
@ -30,5 +41,41 @@ class SkyBlockTweaks {
MinecraftForge.EVENT_BUS.register(GrottoFinder)
MinecraftForge.EVENT_BUS.register(ChestEsp)
MinecraftForge.EVENT_BUS.register(GemstoneFinder)
ClientCommandHandler.instance.registerCommand(SBTCommand())
}
private fun loadConfig() {
config.load()
val powderChestEnable = config.getBoolean(
"powderchestenable",
Configuration.CATEGORY_GENERAL,
true,
"Enables/Disables Powder ChestESP"
)
ChestEsp.enabled = powderChestEnable
val gemstoneRadius = config.getInt(
"gemstonesearchradius",
Configuration.CATEGORY_GENERAL,
16,
1,
256,
"Enables/Disables Powder ChestESP"
)
ChestEsp.enabled = powderChestEnable
GemstoneFinder.radius = gemstoneRadius
if (config.hasChanged()) {
config.save()
}
}
fun syncConfig() {
loadConfig()
if (config.hasChanged()) {
config.save()
}
}
}

View File

@ -1,5 +1,6 @@
package com.github.itzilly.sbt.features
import com.github.itzilly.sbt.SkyBlockTweaks
import com.github.itzilly.sbt.renderer.RenderUtils
import java.awt.Color
import com.github.itzilly.sbt.util.Chatterbox
@ -16,6 +17,7 @@ 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.common.config.Configuration
import net.minecraftforge.event.entity.player.PlayerInteractEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.opengl.GL11
@ -32,9 +34,11 @@ fun chestNodeExists(x: Int, y: Int, z: Int): Boolean {
}
object ChestEsp {
var chestList: ArrayList<ChestNode> = ArrayList()
var enabled: Boolean = SkyBlockTweaks.config.getBoolean("powderchestenable", Configuration.CATEGORY_GENERAL, true, "Enables/Disables Powder ChestESP")
@SubscribeEvent
fun chatMessageEvent(event: ClientChatReceivedEvent) {
if (!enabled) return
if (event.message.unformattedText == "You uncovered a treasure chest!") {
DelayedFunction({ highlightChests() }, 5)
}
@ -42,6 +46,7 @@ object ChestEsp {
@SubscribeEvent
fun renderBlockOverlay(event: RenderWorldLastEvent) {
if (!enabled) return
val player = Minecraft.getMinecraft().thePlayer
for (chest: ChestNode in chestList) {
@ -53,6 +58,7 @@ object ChestEsp {
@SubscribeEvent
fun rightClickEvent(event: PlayerInteractEvent) {
if (!enabled) return
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
val player = event.entityPlayer
val reachDistance = 5.0
@ -75,12 +81,12 @@ object ChestEsp {
if (chestNodeExists(x, y, z)) {
chestList.removeIf { it.x == x && it.y == y && it.z == z }
}
}
}
}
fun highlightChests() {
if (!enabled) return
val searchRadius = 8
val world = Minecraft.getMinecraft().thePlayer.worldObj
val posX = Minecraft.getMinecraft().thePlayer.posX
@ -96,7 +102,6 @@ object ChestEsp {
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()) {
@ -110,7 +115,6 @@ object ChestEsp {
}
}
}
// Chatterbox.say(SimpleChatMsg("Done!").green())
}

View File

@ -0,0 +1,37 @@
package com.github.itzilly.sbt.features
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent
object FarmHelper {
// private val mc: Minecraft = Minecraft.getMinecraft()
// private var isPressingD = false
// private var isPressingMouse = false
// @SubscribeEvent
// fun onPlayerTick(event: PlayerTickEvent) {
// if (event.player === mc.thePlayer) {
// if (isPressingD) {
// mc.thePlayer.moveStrafing = 1.0f // Simulate holding 'd'
// }
// if (isPressingMouse) {
// mc.gameSettings.keyBindAttack.setPressed(true) // Simulate mouse button down
// }
// }
// }
//
// @SubscribeEvent
// fun onKeyInput(event: KeyInputEvent) {
// if (mc.currentScreen == null) {
// if (event.getKey() === GLFW.GLFW_KEY_P && event.getAction() === GLFW.GLFW_PRESS) {
// isPressingD = !isPressingD // Toggle 'd' key
// }
// if (event.getKey() === GLFW.GLFW_KEY_O && event.getAction() === GLFW.GLFW_PRESS) {
// isPressingMouse = !isPressingMouse // Toggle mouse button
// mc.gameSettings.keyBindAttack.setPressed(isPressingMouse) // Set initial state
// }
// }
// }
}

View File

@ -1,10 +1,12 @@
package com.github.itzilly.sbt.features
import com.github.itzilly.sbt.SkyBlockTweaks
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.common.config.Configuration
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
enum class GemstoneColors(val color: Int) {
@ -19,6 +21,7 @@ enum class GemstoneColors(val color: Int) {
object GemstoneFinder {
private var gemstoneList: ArrayList<GemstoneBlock> = ArrayList()
var radius = SkyBlockTweaks.config.getCategory(Configuration.CATEGORY_GENERAL)?.get("gemstonesearchradius")?.int?: 16
fun clear() {
gemstoneList.clear()
@ -28,15 +31,15 @@ object GemstoneFinder {
val playerPos = Minecraft.getMinecraft().thePlayer.position
val minBounds = BlockPos(
playerPos.x - 32,
maxOf(playerPos.y - 32, 31),
playerPos.z - 32
playerPos.x - radius,
maxOf(playerPos.y - radius, 31),
playerPos.z - radius
)
val maxBounds = BlockPos(
playerPos.x + 32,
minOf(playerPos.y + 32, 188),
playerPos.z + 32
playerPos.x + radius,
minOf(playerPos.y + radius, 188),
playerPos.z + radius
)
val world = Minecraft.getMinecraft().thePlayer.worldObj

View File

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

View File

@ -0,0 +1,18 @@
package com.github.itzilly.sbt.renderer
import net.minecraft.client.Minecraft
import net.minecraft.util.BlockPos
import net.minecraftforge.client.event.RenderWorldLastEvent
class RenderableBlockOutline(val x: Int, val y: Int, val z: Int, val outlineColor: Int) {
fun renderOutline(event: RenderWorldLastEvent) {
val player = Minecraft.getMinecraft().thePlayer
val pos = BlockPos(x, y, z)
RenderFuncs.drawBlockOutline(player, pos, event.partialTicks, outlineColor)
}
fun renderLine(event: RenderWorldLastEvent) {
val pos = BlockPos(x, y, z)
RenderFuncs.drawBlockLine(pos, event.partialTicks)
}
}