Clean Project

This commit is contained in:
illyum 2025-04-22 00:22:06 -06:00
parent 2c0643c274
commit 09ed358681
3 changed files with 0 additions and 450 deletions

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

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

View File

@ -1,314 +0,0 @@
package com.github.itzilly.sbt
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.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
@Mod(modid = "sbt", useMetadata = true)
class SkyBlockTweaks {
init {
INSTANCE = this
}
companion object {
lateinit var INSTANCE: SkyBlockTweaks
var routeList: ArrayList<RouteMarker> = ArrayList()
}
lateinit var tessellator: Tessellator
lateinit var worldRenderer: WorldRenderer
lateinit var renderManager: RenderManager
lateinit var fontRenderer: FontRenderer
private var renderWorldList: ArrayList<RenderHudAble> = 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)
}
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())
}
// @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)
}
}
}
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
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)
}
}
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)
if (!isPointInRouteList(SkyBlockTweaks.routeList, x, y, z)) {
val name = SkyBlockTweaks.routeList.size + 1
val point = RouteMarker(x, y, z, 0u, 1u, 0u, RouteOptions(name.toString()))
SkyBlockTweaks.routeList.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(SkyBlockTweaks.routeList)
setClipboard(jsonString)
SkyBlockTweaks.routeList.clear()
}
else if (STBKeyBinds.clearWaypoints.isPressed) {
SkyBlockTweaks.routeList.clear()
mc.thePlayer.addChatMessage(ChatComponentText("Reset current route"))
}
else if (STBKeyBinds.openRoutesGui.isPressed) {
mc.displayGuiScreen(RouteGui())
}
}
}
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<RouteMarker>, 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)
val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard
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)
}
}
}
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)
}
}
}