diff --git a/.kotlin/errors/errors-1721778737330.log b/.kotlin/errors/errors-1721778737330.log new file mode 100644 index 0000000..d7c30bc --- /dev/null +++ b/.kotlin/errors/errors-1721778737330.log @@ -0,0 +1,73 @@ +kotlin version: 2.0.0 +error message: Daemon compilation failed: null +java.lang.Exception + at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:69) + at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:65) + at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:240) + at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:159) + at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:111) + at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction.execute(GradleCompilerRunnerWithWorkers.kt:76) + at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62) + at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62) + at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44) + at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41) + at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209) + at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204) + at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) + at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) + at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166) + at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59) + at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53) + at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41) + at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59) + at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:174) + at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162) + at org.gradle.internal.Factories$1.create(Factories.java:31) + at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:264) + at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:128) + at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:133) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157) + at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126) + at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) + at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) + at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) + at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47) + at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) + at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) + at java.base/java.lang.Thread.run(Thread.java:833) +Caused by: java.nio.file.NoSuchFileException: C:\Users\illyum\AppData\Local\Temp\kotlin-backups14211537242402827334\7.backup -> O:\Kotlin Programming\sbt\build\classes\java\main\com\github\itzilly\sbt\KeyInputHandler.class + at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85) + at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) + at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:403) + at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:293) + at java.base/java.nio.file.Files.move(Files.java:1432) + at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.revertChanges(CompilationTransaction.kt:231) + at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.close(CompilationTransaction.kt:256) + at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.tryCompileIncrementally(IncrementalCompilerRunner.kt:747) + at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:120) + at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:676) + at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92) + at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1661) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360) + at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) + at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) + at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) + at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) + at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587) + at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828) + at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705) + at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) + at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704) + ... 3 more + + diff --git a/build.gradle.kts b/build.gradle.kts index 00586ef..4434991 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -152,3 +152,27 @@ tasks.shadowJar { tasks.assemble.get().dependsOn(tasks.remapJar) +tasks.register("illyExtractMappings") { + from("O:/.gradle") + into("${layout.buildDirectory}/mcp_mappings") +} + +tasks.register("illyApplyMappings") { + dependsOn("illyExtractMappings") + doLast { +// throw GradleException("${layout.buildDirectory.d}/mcp_mappings") + val mappingsDir = file("O:/Kotlin Programming/sbt/build/mcp_mappings") + if (mappingsDir.exists()) { + project.ext.set("mappingsPath", mappingsDir.absolutePath) + } else { + throw GradleException("Mappings directory not found!") + } + } +} + +tasks.withType { + dependsOn("illyApplyMappings") + doLast { + options.compilerArgs.add("-Amap=O:/Kotlin Programming/sbt/build/mcp_mappings") + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6d9ab6f..ef07eac 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.0 +version = 1.0.1 diff --git a/src/main/kotlin/com/github/itzilly/sbt/HudText.kt b/src/main/kotlin/com/github/itzilly/sbt/HudText.kt index fd057e7..d2f1a58 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/HudText.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/HudText.kt @@ -3,22 +3,22 @@ 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 +//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/RenderUtils.kt b/src/main/kotlin/com/github/itzilly/sbt/RenderUtils.kt deleted file mode 100644 index c09d84d..0000000 --- a/src/main/kotlin/com/github/itzilly/sbt/RenderUtils.kt +++ /dev/null @@ -1,112 +0,0 @@ -package com.github.itzilly.sbt - -import net.minecraft.client.renderer.Tessellator -import net.minecraft.client.renderer.WorldRenderer -import net.minecraft.client.renderer.vertex.DefaultVertexFormats -import net.minecraft.util.AxisAlignedBB -import java.awt.Color - - -class RenderUtils { - var TESSELLATOR: Tessellator = Tessellator.getInstance() - var WORLD_RENDERER: WorldRenderer = Tessellator.getInstance().worldRenderer - - fun drawBlock(box: AxisAlignedBB, outlineStartColor: Int, outlineEndColor: Int) { - drawBlockTop(box, Color(outlineStartColor), Color(outlineEndColor)); - drawBlockBottom(box, Color(outlineStartColor), Color(outlineEndColor)); - drawBlockNorth(box, Color(outlineStartColor), Color(outlineEndColor)); - drawBlockEast(box, Color(outlineStartColor), Color(outlineEndColor)); - drawBlockSouth(box, Color(outlineStartColor), Color(outlineEndColor)); - drawBlockWest(box, Color(outlineStartColor), Color(outlineEndColor)); - } - - private fun drawBlockTop(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { - WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) - WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - TESSELLATOR.draw() - } - - private fun drawBlockBottom(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { - WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) - WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.minX, box.minY, box.minZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - TESSELLATOR.draw() - } - - private fun drawBlockNorth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { - WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) - WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - TESSELLATOR.draw() - } - - private fun drawBlockEast(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { - WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) - WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - TESSELLATOR.draw() - } - - private fun drawBlockSouth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { - WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) - WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.minX, box.minY, box.minZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - TESSELLATOR.draw() - } - - private fun drawBlockWest(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { - WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) - WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ) - .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) - .endVertex() - WORLD_RENDERER.pos(box.minX, box.minY, box.minZ) - .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() - TESSELLATOR.draw() - } -} \ 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 new file mode 100644 index 0000000..12b1070 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/STBKeyBindings.kt @@ -0,0 +1,51 @@ +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 ceef2f4..246f6b6 100644 --- a/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt +++ b/src/main/kotlin/com/github/itzilly/sbt/SkyBlockTweaks.kt @@ -1,35 +1,25 @@ 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 net.minecraft.block.Block import net.minecraft.client.Minecraft -import net.minecraft.client.gui.* -import net.minecraft.client.renderer.GlStateManager -import net.minecraft.client.renderer.Tessellator -import net.minecraft.client.renderer.WorldRenderer -import net.minecraft.client.renderer.entity.RenderManager -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 -import net.minecraftforge.client.event.RenderGameOverlayEvent -import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.common.MinecraftForge -import net.minecraftforge.fml.client.registry.ClientRegistry 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.input.Keyboard 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) @@ -40,114 +30,43 @@ class SkyBlockTweaks { companion object { lateinit var INSTANCE: SkyBlockTweaks - var routeList: ArrayList = ArrayList() } - lateinit var tessellator: Tessellator - lateinit var worldRenderer: WorldRenderer - lateinit var renderManager: RenderManager - lateinit var fontRenderer: FontRenderer - - private var renderWorldList: ArrayList = ArrayList() - - @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, java.lang.System.out) - } catch (e: java.io.IOException) { - throw java.lang.RuntimeException(e) - } +// 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() + // STBKeyBinds.init() - tessellator = Tessellator.getInstance() - worldRenderer = tessellator.worldRenderer - renderManager = Minecraft.getMinecraft().renderManager - fontRenderer = Minecraft.getMinecraft().fontRendererObj +// MinecraftForge.EVENT_BUS.register(this) +// MinecraftForge.EVENT_BUS.register(KeyInputHandler()) +// MinecraftForge.EVENT_BUS.register(RouteMarkerRender) +// MinecraftForge.EVENT_BUS.register(LockedChestEsp) - MinecraftForge.EVENT_BUS.register(this) - MinecraftForge.EVENT_BUS.register(KeyInputHandler()) - MinecraftForge.EVENT_BUS.register(RouteMarkerRender()) - } - -// @SubscribeEvent -// fun worldLoadEvent(event: WorldEvent.Load) { -// val msg = "Hello illy!" -// renderWorldList.add( -// HudText( -// arrayOf(msg), -// (Display.getWidth() / 2), -// Display.getHeight() / 2 / 2, -// false -// ) -// ) -// } - - @SubscribeEvent - fun renderOverlayEvent(event: RenderGameOverlayEvent.Text) { - if (renderWorldList.size == 0) { - return - } - for (render: RenderHudAble in renderWorldList) { - render.render(event.partialTicks) - } + MinecraftForge.EVENT_BUS.register(RouteBuilder) } } - -interface RenderHudAble { - fun render(partialTicks: Float) -} - - -interface RenderWorldAble { - fun render(partialTicks: Float) -} - - -object STBKeyBinds { - lateinit var addWaypoint: KeyBinding - 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") - 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) - } -} - - class KeyInputHandler { private val mc = Minecraft.getMinecraft() @SubscribeEvent fun onKeyInput(event: InputEvent.KeyInputEvent?) { if (STBKeyBinds.addWaypoint.isPressed) { - val x = mc.thePlayer.posX.toInt() - val y = mc.thePlayer.posY.toInt() - val z = mc.thePlayer.posZ.toInt() - 1 // Offset from player (no clue why I need this) + 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(SkyBlockTweaks.routeList, x, y, z)) { - val name = SkyBlockTweaks.routeList.size + 1 + if (!isPointInRouteList(markerList, x, y, z)) { + val name = markerList.size + 1 val point = RouteMarker(x, y, z, 0u, 1u, 0u, RouteOptions(name.toString())) - SkyBlockTweaks.routeList.add(point) + 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")) @@ -155,11 +74,11 @@ class KeyInputHandler { } else if (STBKeyBinds.finishWaypoints.isPressed) { mc.thePlayer.addChatMessage(ChatComponentText("Finished route! Copied route to clipboard")) - val jsonString = Gson().toJson(SkyBlockTweaks.routeList) + val jsonString = Gson().toJson(markerList) setClipboard(jsonString) - SkyBlockTweaks.routeList.clear() + markerList.clear() } else if (STBKeyBinds.clearWaypoints.isPressed) { - SkyBlockTweaks.routeList.clear() + markerList.clear() mc.thePlayer.addChatMessage(ChatComponentText("Reset current route")) } else if (STBKeyBinds.openRoutesGui.isPressed) { mc.displayGuiScreen(RouteGui()) @@ -167,66 +86,8 @@ class KeyInputHandler { 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...")) - 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 = 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( - val x: Int, - val y: Int, - val z: Int, - - val r: UByte, - val g: UByte, - val b: UByte, - - val options: RouteOptions -) - -fun isPointInRouteList(routeList: List, x: Int, y: Int, z: Int): Boolean { - return routeList.any { it.x == x && it.y == y && it.z == z } -} - -data class RouteOptions( - val name: String -) fun setClipboard(s: String) { val selection = StringSelection(s) @@ -234,131 +95,37 @@ fun setClipboard(s: String) { clipboard.setContents(selection, selection) } -class RouteMarkerRender { - @SubscribeEvent - fun renderBlockOverlay(event: RenderWorldLastEvent) { - val player = Minecraft.getMinecraft().thePlayer - for (marker: RouteMarker in SkyBlockTweaks.routeList) { - val pos = BlockPos(marker.x, marker.y, marker.z) - renderPoint(player, pos, event.partialTicks) - } +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) } } - - -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() -} - - -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 SkyBlockTweaks.routeList.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) - } - } - -} - diff --git a/src/main/kotlin/com/github/itzilly/sbt/features/RouteBuilder.kt b/src/main/kotlin/com/github/itzilly/sbt/features/RouteBuilder.kt new file mode 100644 index 0000000..cbd6aec --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/RouteBuilder.kt @@ -0,0 +1,102 @@ +package com.github.itzilly.sbt.features + +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.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 kotlin.math.round + +object RouteBuilder { + var addNodeKeybind: KeyBinding + var deleteLastNodeKeybind: KeyBinding + var finishRouteKeybind: KeyBinding + + var nodes: ArrayList = ArrayList() + + + init { + addNodeKeybind = KeyBinding("key.addNode", Keyboard.KEY_ADD, "key.categories.sbt") + ClientRegistry.registerKeyBinding(addNodeKeybind) + + deleteLastNodeKeybind = KeyBinding("key.removeLastNode", Keyboard.KEY_MINUS, "key.categories.sbt") + ClientRegistry.registerKeyBinding(deleteLastNodeKeybind) + + finishRouteKeybind = KeyBinding("key.finishRoute", Keyboard.KEY_F4, "key.categories.sbt") + ClientRegistry.registerKeyBinding(finishRouteKeybind) + } + + + @SubscribeEvent + fun onKeyInput(event: InputEvent.KeyInputEvent) { + if (addNodeKeybind.isPressed) { + val mc = Minecraft.getMinecraft() + 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 (nodeExists(x, y, z)) { + Chatterbox.say(SimpleChatMsg("Node already exists!").red()) + } else { + addNode(x, y, z) + Chatterbox.say("This is a string") + } + } + + if (deleteLastNodeKeybind.isPressed) { + val wasRemoved = nodes.removeLastOrNull() + if (wasRemoved == null) { + val msg = SimpleChatMsg("There isn't a node to delete!") + Chatterbox.say(msg.red()) + } else { + val msg = SimpleChatMsg("Removed previous node") + Chatterbox.say(msg.green()) + } + } + + if (finishRouteKeybind.isPressed) { + if (nodes.size == 0) { + val msg = SimpleChatMsg("There aren't any nodes to copy!") + Chatterbox.say(msg.red()) + } else { + val jsonString = Gson().toJson(nodes) + val msg = SimpleChatMsg("String copied to clipboard!") + setClipboard(jsonString) + Chatterbox.say(msg.green()) + } + } + } + + fun addNode(x: Int, y: Int, z: Int) { + nodes.add(RouteNode(x, y, z, 0u, 1u, 0u, NodeOptions("${nodes.size + 1}"))) + } + + 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}"))) + } +} + +data class RouteNode( + val x: Int, + val y: Int, + val z: Int, + + val r: UByte, + val g: UByte, + val b: UByte, + + val options: NodeOptions +) + +data class NodeOptions( + val name: String +) + +fun nodeExists(x: Int, y: Int, z: Int): Boolean { + return RouteBuilder.nodes.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/mining/lockedChestESP/ChestESPRender.kt b/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/ChestESPRender.kt new file mode 100644 index 0000000..b0612de --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/ChestESPRender.kt @@ -0,0 +1,89 @@ +package com.github.itzilly.sbt.features.mining.lockedChestESP + +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 +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 ChestESPRender { + @SubscribeEvent + fun renderBlockOverlay(event: RenderWorldLastEvent) { + val player = Minecraft.getMinecraft().thePlayer + + for (marker: RouteNode in LockedChestEsp.chestsList) { + 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/mining/lockedChestESP/LockedChestEsp.kt b/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/LockedChestEsp.kt new file mode 100644 index 0000000..1b9946a --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/mining/lockedChestESP/LockedChestEsp.kt @@ -0,0 +1,113 @@ +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 new file mode 100644 index 0000000..48f998a --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/GuiStuff.kt @@ -0,0 +1,83 @@ +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 new file mode 100644 index 0000000..575cb1c --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMaker.kt @@ -0,0 +1,5 @@ +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/RouteMarker.kt b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarker.kt new file mode 100644 index 0000000..9697cde --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarker.kt @@ -0,0 +1,25 @@ +package com.github.itzilly.sbt.features.mining.routeMaker + + +data class RouteMarker( + val x: Int, + val y: Int, + val z: Int, + + val r: UByte, + val g: UByte, + val b: UByte, + + val options: RouteOptions +) + +data class RouteOptions( + val name: String +) + +fun isPointInRouteList(routeList: ArrayList, x: Int, y: Int, z: Int): Boolean { + return routeList.any { it.x == x && it.y == y && it.z == z } +} + + + 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 new file mode 100644 index 0000000..e47a582 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/features/mining/routeMaker/RouteMarkerRender.kt @@ -0,0 +1,85 @@ +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/mixin/RenderManagerAccessor.kt b/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerAccessor.kt new file mode 100644 index 0000000..f2a43e5 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerAccessor.kt @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..da54dc1 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/mixin/RenderManagerMixin.kt @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000..2b041ac --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/mycrap.kt @@ -0,0 +1,95 @@ +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/renderer/RenderUtils.kt b/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderUtils.kt new file mode 100644 index 0000000..5dab7df --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/renderer/RenderUtils.kt @@ -0,0 +1,258 @@ +package com.github.itzilly.sbt.renderer + +import com.github.itzilly.sbt.util.Vecd3 +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.client.renderer.Tessellator +import net.minecraft.client.renderer.WorldRenderer +import net.minecraft.client.renderer.vertex.DefaultVertexFormats +import net.minecraft.util.AxisAlignedBB +import org.lwjgl.opengl.GL11 +import java.awt.Color + +object RenderUtils { + var TESSELLATOR: Tessellator = Tessellator.getInstance() + var WORLD_RENDERER: WorldRenderer = Tessellator.getInstance().worldRenderer + + fun drawBlock(box: AxisAlignedBB, outlineStartColor: Int, outlineEndColor: Int) { + drawBlockTop(box, Color(outlineStartColor), Color(outlineEndColor)); + drawBlockBottom(box, Color(outlineStartColor), Color(outlineEndColor)); + drawBlockNorth(box, Color(outlineStartColor), Color(outlineEndColor)); + drawBlockEast(box, Color(outlineStartColor), Color(outlineEndColor)); + drawBlockSouth(box, Color(outlineStartColor), Color(outlineEndColor)); + drawBlockWest(box, Color(outlineStartColor), Color(outlineEndColor)); + } + + private fun drawBlockTop(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + private fun drawBlockBottom(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.minY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + private fun drawBlockNorth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + private fun drawBlockEast(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.maxX, box.maxY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + private fun drawBlockSouth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.minY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + private fun drawBlockWest(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color) { + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.minX, box.maxY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.maxY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.minX, box.minY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.minY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + fun drawLine(p1: Vecd3, p2: Vecd3, color: Color, lineWidth: Int, depth: Boolean, partialTicks: Float) { + GlStateManager.disableCull() + + val render = Minecraft.getMinecraft().renderViewEntity + val worldRenderer = TESSELLATOR.worldRenderer + + val realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks + val realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks + val realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks + + + GlStateManager.pushMatrix() + GlStateManager.translate(-realX, -realY, -realZ) + GlStateManager.disableTexture2D() + GlStateManager.enableBlend() + GlStateManager.disableAlpha() + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) + GL11.glLineWidth(lineWidth.toFloat()) + if (!depth) { + GL11.glDisable(GL11.GL_DEPTH_TEST) + GlStateManager.depthMask(false) + } + GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f) + worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION) + worldRenderer.pos(p1.x, p1.y, p1.z).endVertex() + worldRenderer.pos(p2.x, p2.y, p2.z).endVertex() + Tessellator.getInstance().draw() + GlStateManager.translate(realX, realY, realZ) + if (!depth) { + GL11.glEnable(GL11.GL_DEPTH_TEST) + GlStateManager.depthMask(true) + } + GlStateManager.disableBlend() + GlStateManager.enableAlpha() + GlStateManager.enableTexture2D() + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f) + GlStateManager.popMatrix() + GlStateManager.disableLighting() + GlStateManager.enableCull() + } + + fun drawAnimatedBlockTop(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color, time: Float) { + val offsetY = Math.sin(time.toDouble()).toFloat() * (box.maxY - box.minY) / 2.0f + + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.minX, box.maxY + offsetY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY + offsetY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY + offsetY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.maxY + offsetY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + fun drawAnimatedBlockBottom(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color, time: Float) { + val offsetY = Math.sin(time.toDouble()).toFloat() * (box.maxY - box.minY) / 2.0f + + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.maxX, box.minY + offsetY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.minY + offsetY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.minX, box.minY + offsetY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY + offsetY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + fun drawAnimatedBlockNorth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color, time: Float) { + val offsetY = Math.sin(time.toDouble()).toFloat() * (box.maxY - box.minY) / 2.0f + + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.maxX, box.maxY + offsetY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY + offsetY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.minX, box.minY + offsetY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.maxY + offsetY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + fun drawAnimatedBlockEast(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color, time: Float) { + val offsetY = Math.sin(time.toDouble()).toFloat() * (box.maxY - box.minY) / 2.0f + + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.maxX, box.maxY + offsetY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY + offsetY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY + offsetY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY + offsetY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + fun drawAnimatedBlockSouth(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color, time: Float) { + val offsetY = Math.sin(time.toDouble()).toFloat() * (box.maxY - box.minY) / 2.0f + + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.minX, box.maxY + offsetY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.minY + offsetY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.maxX, box.minY + offsetY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.maxX, box.maxY + offsetY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } + + fun drawAnimatedBlockWest(box: AxisAlignedBB, outlineStartColor: Color, outlineEndColor: Color, time: Float) { + val offsetY = Math.sin(time.toDouble()).toFloat() * (box.maxY - box.minY) / 2.0f + + WORLD_RENDERER.begin(2, DefaultVertexFormats.POSITION_COLOR) + WORLD_RENDERER.pos(box.minX, box.maxY + offsetY, box.minZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.maxY + offsetY, box.maxZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + WORLD_RENDERER.pos(box.minX, box.minY + offsetY, box.maxZ) + .color(outlineStartColor.red, outlineStartColor.green, outlineStartColor.blue, outlineStartColor.alpha) + .endVertex() + WORLD_RENDERER.pos(box.minX, box.minY + offsetY, box.minZ) + .color(outlineEndColor.red, outlineEndColor.green, outlineEndColor.blue, outlineEndColor.alpha).endVertex() + TESSELLATOR.draw() + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/util/Chatterbox.kt b/src/main/kotlin/com/github/itzilly/sbt/util/Chatterbox.kt new file mode 100644 index 0000000..4591dbb --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/util/Chatterbox.kt @@ -0,0 +1,36 @@ +package com.github.itzilly.sbt.util + +import net.minecraft.client.Minecraft +import net.minecraft.util.ChatComponentText +import net.minecraft.util.ChatStyle +import net.minecraft.util.EnumChatFormatting +import net.minecraft.util.IChatComponent + +object Chatterbox { + private const val prefixString = "[SBT] " + private val prefixColorStyle = ChatStyle().setColor(EnumChatFormatting.AQUA) + private val prefixComponent = ChatComponentText(prefixString).setChatStyle(prefixColorStyle) + private val player = Minecraft.getMinecraft().thePlayer + + private fun copy(component: IChatComponent): IChatComponent { + val newComponent = ChatComponentText(component.unformattedTextForChat) + newComponent.chatStyle = component.chatStyle.createShallowCopy() + component.siblings.forEach { sibling -> + newComponent.appendSibling(copy(sibling)) + } + return newComponent + } + + fun say(msg: String) { + val messageComponent = ChatComponentText(msg).setChatStyle(ChatStyle().setColor(EnumChatFormatting.RESET)) + player.addChatMessage(prefixComponent.createCopy().appendSibling(messageComponent)) + } + + fun say(component: ChatComponentText) { + player.addChatMessage(copy(prefixComponent).appendSibling(copy(component))) + } + + fun say(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/DelayedFunction.kt b/src/main/kotlin/com/github/itzilly/sbt/util/DelayedFunction.kt new file mode 100644 index 0000000..9455675 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/util/DelayedFunction.kt @@ -0,0 +1,25 @@ +package com.github.itzilly.sbt.util + +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + + +class DelayedFunction(private val function: () -> Unit, private val delayTicks: Int) { + private var ticksLeft: Int = delayTicks + + init { + MinecraftForge.EVENT_BUS.register(this) + } + + @SubscribeEvent + fun onClientTick(event: TickEvent.ClientTickEvent) { + if (ticksLeft > 0) { + ticksLeft-- + if (ticksLeft == 0) { + function() + MinecraftForge.EVENT_BUS.unregister(this) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/util/SimpleChatMsg.kt b/src/main/kotlin/com/github/itzilly/sbt/util/SimpleChatMsg.kt new file mode 100644 index 0000000..a4f12de --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/util/SimpleChatMsg.kt @@ -0,0 +1,146 @@ +package com.github.itzilly.sbt.util + +import net.minecraft.util.ChatComponentText +import net.minecraft.util.ChatStyle +import net.minecraft.util.EnumChatFormatting.BLACK +import net.minecraft.util.EnumChatFormatting.DARK_BLUE +import net.minecraft.util.EnumChatFormatting.DARK_GREEN +import net.minecraft.util.EnumChatFormatting.DARK_AQUA +import net.minecraft.util.EnumChatFormatting.DARK_RED +import net.minecraft.util.EnumChatFormatting.DARK_PURPLE +import net.minecraft.util.EnumChatFormatting.GOLD +import net.minecraft.util.EnumChatFormatting.GRAY +import net.minecraft.util.EnumChatFormatting.DARK_GRAY +import net.minecraft.util.EnumChatFormatting.BLUE +import net.minecraft.util.EnumChatFormatting.GREEN +import net.minecraft.util.EnumChatFormatting.AQUA +import net.minecraft.util.EnumChatFormatting.RED +import net.minecraft.util.EnumChatFormatting.LIGHT_PURPLE +import net.minecraft.util.EnumChatFormatting.YELLOW +import net.minecraft.util.EnumChatFormatting.WHITE +import net.minecraft.util.EnumChatFormatting.OBFUSCATED +import net.minecraft.util.EnumChatFormatting.BOLD +import net.minecraft.util.EnumChatFormatting.STRIKETHROUGH +import net.minecraft.util.EnumChatFormatting.UNDERLINE +import net.minecraft.util.EnumChatFormatting.ITALIC +import net.minecraft.util.EnumChatFormatting.RESET +import net.minecraft.util.IChatComponent + +class SimpleChatMsg(msg: String) { + private var component: IChatComponent + + init { + component = ChatComponentText(msg) + } + + + fun default(): IChatComponent { + component.chatStyle = ChatStyle().setColor(RESET) + return component + } + + fun black(): IChatComponent { + component.chatStyle = ChatStyle().setColor(BLACK) + return component + } + + fun dark_blue(): IChatComponent { + component.chatStyle = ChatStyle().setColor(DARK_BLUE) + return component + } + + fun dark_green(): IChatComponent { + component.chatStyle = ChatStyle().setColor(DARK_GREEN) + return component + } + + fun dark_aqua(): IChatComponent { + component.chatStyle = ChatStyle().setColor(DARK_AQUA) + return component + } + + fun dark_red(): IChatComponent { + component.chatStyle = ChatStyle().setColor(DARK_RED) + return component + } + + fun dark_purple(): IChatComponent { + component.chatStyle = ChatStyle().setColor(DARK_PURPLE) + return component + } + + fun gold(): IChatComponent { + component.chatStyle = ChatStyle().setColor(GOLD) + return component + } + + fun gray(): IChatComponent { + component.chatStyle = ChatStyle().setColor(GRAY) + return component + } + + fun dark_gray(): IChatComponent { + component.chatStyle = ChatStyle().setColor(DARK_GRAY) + return component + } + + fun blue(): IChatComponent { + component.chatStyle = ChatStyle().setColor(BLUE) + return component + } + + fun green(): IChatComponent { + component.chatStyle = ChatStyle().setColor(GREEN) + return component + } + + fun aqua(): IChatComponent { + component.chatStyle = ChatStyle().setColor(AQUA) + return component + } + + fun red(): IChatComponent { + component.chatStyle = ChatStyle().setColor(RED) + return component + } + + fun light_purple(): IChatComponent { + component.chatStyle = ChatStyle().setColor(LIGHT_PURPLE) + return component + } + + fun yellow(): IChatComponent { + component.chatStyle = ChatStyle().setColor(YELLOW) + return component + } + + fun white(): IChatComponent { + component.chatStyle = ChatStyle().setColor(WHITE) + return component + } + + fun obfuscated(): IChatComponent { + component.chatStyle = ChatStyle().setColor(OBFUSCATED) + return component + } + + fun bold(): IChatComponent { + component.chatStyle = ChatStyle().setColor(BOLD) + return component + } + + fun strikethrough(): IChatComponent { + component.chatStyle = ChatStyle().setColor(STRIKETHROUGH) + return component + } + + fun underline(): IChatComponent { + component.chatStyle = ChatStyle().setColor(UNDERLINE) + return component + } + + fun italic(): IChatComponent { + component.chatStyle = ChatStyle().setColor(ITALIC) + return component + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/itzilly/sbt/util/datatypes.kt b/src/main/kotlin/com/github/itzilly/sbt/util/datatypes.kt new file mode 100644 index 0000000..4bec9a4 --- /dev/null +++ b/src/main/kotlin/com/github/itzilly/sbt/util/datatypes.kt @@ -0,0 +1,4 @@ +package com.github.itzilly.sbt.util + +data class Vecd3(val x:Double, val y:Double, val z:Double) +data class Vecf3(val x:Float, val y:Float, val z:Float) \ No newline at end of file