diff options
author | inglettronald <71849533+inglettronald@users.noreply.github.com> | 2023-06-05 17:18:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 17:18:52 -0500 |
commit | e209c2c0e3148bfec9cae51b5561c0918c88f479 (patch) | |
tree | 3dbdaa7eb6bd52fbc6f3dad38a73cfe1c54359ee | |
parent | b220e76e12724a91507e894ac018e1ad6b695c9a (diff) | |
parent | 89bf4d23a30c02b341df0048bc0717142af1a9ff (diff) | |
download | DulkirMod-e209c2c0e3148bfec9cae51b5561c0918c88f479.tar.gz DulkirMod-e209c2c0e3148bfec9cae51b5561c0918c88f479.tar.bz2 DulkirMod-e209c2c0e3148bfec9cae51b5561c0918c88f479.zip |
Merge pull request #19 from IlmarsXd/cleanup
Some cleanup
-rw-r--r-- | src/main/kotlin/dulkirmod/DulkirMod.kt | 1 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt | 80 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt | 3 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/rift/IchorHighlight.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/utils/TablistUtils.kt | 87 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/utils/WorldRenderUtils.kt | 308 | ||||
-rw-r--r-- | src/main/resources/mixins.dulkirmod.json | 6 |
7 files changed, 218 insertions, 271 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt index 382c936..88b032a 100644 --- a/src/main/kotlin/dulkirmod/DulkirMod.kt +++ b/src/main/kotlin/dulkirmod/DulkirMod.kt @@ -28,6 +28,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent import org.lwjgl.input.Keyboard import java.io.File +import java.lang.management.ManagementFactory import kotlin.coroutines.EmptyCoroutineContext @Mod( diff --git a/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt b/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt index edf3114..48cddb8 100644 --- a/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt +++ b/src/main/kotlin/dulkirmod/features/BlazeSlayerFeatures.kt @@ -13,6 +13,13 @@ object BlazeSlayerFeatures { private val minibosses = "(Flare Demon)|(Kindleheart Demon)|(Burningsoul Demon)".toRegex() + private val phaseColors = listOf( + "CRYSTAL ♨" to Color(15, 247, 236, 200), + "ASHEN ♨" to Color(40, 40, 40, 200), + "AURIC ♨" to Color(206, 219, 57, 200), + "SPIRIT ♨" to Color(255, 255, 255, 200) + ) + @SubscribeEvent fun onRenderLiving(event: RenderLivingEvent.Post<*>) { if (!(DulkirConfig.attunementDisplay || DulkirConfig.minibossHitbox)) return @@ -22,63 +29,18 @@ object BlazeSlayerFeatures { if (event.entity is EntityArmorStand && event.entity.hasCustomName()) { val name = Utils.stripColorCodes(event.entity.customNameTag) val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z) - when { - name.contains("CRYSTAL ♨") -> { - WorldRenderUtils.drawCustomBox( - x - .5, - 1.0, - y - 2, - 1.5, - z - .5, - 1.0, - Color(15, 247, 236, 255), - 3f, - phase = false - ) - } - - name.contains("ASHEN ♨") -> { - WorldRenderUtils.drawCustomBox( - x - .5, - 1.0, - y - 2, - 1.5, - z - .5, - 1.0, - Color(0, 0, 0, 255), - 3f, - phase = false - ) - } - - name.contains("AURIC ♨") -> { - WorldRenderUtils.drawCustomBox( - x - .5, - 1.0, - y - 2, - 1.5, - z - .5, - 1.0, - Color(206, 219, 57, 255), - 3f, - phase = false - ) - } - - name.contains("SPIRIT ♨") -> { - WorldRenderUtils.drawCustomBox( - x - .5, - 1.0, - y - 2, - 1.5, - z - .5, - 1.0, - Color(255, 255, 255, 255), - 3f, - phase = false - ) - } - } + val color = phaseColors.firstOrNull { name.contains(it.first) }?.second ?: return + WorldRenderUtils.drawCustomBox( + x - 0.5, + 1.0, + y - 2, + 1.5, + z - 0.5, + 1.0, + color, + 3f, + phase = false + ) } } @@ -90,11 +52,11 @@ object BlazeSlayerFeatures { if (name.contains(minibosses)) { WorldRenderUtils.drawCustomBox( - x - .5, + x - 0.5, 1.0, y - 1.5, 1.5, - z - .5, + z - 0.5, 1.0, Color(7, 227, 21, 255), 3f, diff --git a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt index 8c891ba..6c8199b 100644 --- a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt +++ b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt @@ -2,13 +2,10 @@ package dulkirmod.features import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.DulkirConfig -import dulkirmod.utils.WorldRenderUtils import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -import java.awt.Color object MemoryLeakFix { private var lastClear = System.currentTimeMillis() diff --git a/src/main/kotlin/dulkirmod/features/rift/IchorHighlight.kt b/src/main/kotlin/dulkirmod/features/rift/IchorHighlight.kt index 580a8b9..4060e32 100644 --- a/src/main/kotlin/dulkirmod/features/rift/IchorHighlight.kt +++ b/src/main/kotlin/dulkirmod/features/rift/IchorHighlight.kt @@ -19,7 +19,7 @@ object IchorHighlight { if (TabListUtils.area != "The Rift") return val entity = event.entity - val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y + 3, event.z) + val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z) if (entity is EntityArmorStand) { if (entity.getEquipmentInSlot(4) != null && entity.getEquipmentInSlot(4).item === Items.skull) { @@ -35,7 +35,7 @@ object IchorHighlight { WorldRenderUtils.drawCustomBox( x - .5, 1.0, - y - 2, + y + 1, 1.0, z - .5, 1.0, diff --git a/src/main/kotlin/dulkirmod/utils/TablistUtils.kt b/src/main/kotlin/dulkirmod/utils/TablistUtils.kt index 8ecc771..7f39e51 100644 --- a/src/main/kotlin/dulkirmod/utils/TablistUtils.kt +++ b/src/main/kotlin/dulkirmod/utils/TablistUtils.kt @@ -6,12 +6,17 @@ import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.DulkirConfig import net.minecraft.client.network.NetworkPlayerInfo import net.minecraft.world.WorldSettings - -val NetworkPlayerInfo.text: String - get() = mc.ingameGUI.tabList.getPlayerName(this) +import net.minecraft.world.WorldSettings.GameType // STOLEN FROM SKYTILS mmm yes object TabListUtils { + val NetworkPlayerInfo.text: String + get() = mc.ingameGUI.tabList.getPlayerName(this) + + private val visitorPattern = "Visitors: \\((.+)\\)".toRegex() + private val nextVisitorPattern = "Next Visitor: (.+)".toRegex() + private val areaPattern = "Area: (.+)".toRegex() + var area: String = "" var explosivity: Boolean = false var maxVisitors: Boolean = false @@ -21,30 +26,23 @@ object TabListUtils { var numVisitors: Int = 0 var archerName: String = "" + var tabEntries = emptyList<Pair<NetworkPlayerInfo, String>>() + private val playerInfoOrdering = object : Ordering<NetworkPlayerInfo>() { - override fun compare(p_compare_1_: NetworkPlayerInfo?, p_compare_2_: NetworkPlayerInfo?): Int { - val scorePlayerTeam = p_compare_1_?.playerTeam - val scorePlayerTeam1 = p_compare_2_?.playerTeam - if (p_compare_1_ != null) { - if (p_compare_2_ != null) { - return ComparisonChain.start().compareTrueFirst( - p_compare_1_.gameType != WorldSettings.GameType.SPECTATOR, - p_compare_2_.gameType != WorldSettings.GameType.SPECTATOR - ).compare( - if (scorePlayerTeam != null) scorePlayerTeam.registeredName else "", - if (scorePlayerTeam1 != null) scorePlayerTeam1.registeredName else "" - ).compare(p_compare_1_.gameProfile.name, p_compare_2_.gameProfile.name).result() - } - return 0 - } - return -1 + override fun compare(info1: NetworkPlayerInfo?, info2: NetworkPlayerInfo?): Int { + if (info1 == null) return -1 + if (info2 == null) return 0 + return ComparisonChain.start() + .compareTrueFirst(!info1.gameType.isSpectator(), !info2.gameType.isSpectator()) + .compare(info1.playerTeam?.registeredName ?: "", info2.playerTeam?.registeredName ?: "") + .compare(info1.gameProfile.name, info2.gameProfile.name).result() } } - var tabEntries: List<Pair<NetworkPlayerInfo, String>> = emptyList() - fun fetchTabEntries(): List<NetworkPlayerInfo> = - if (mc.thePlayer == null) emptyList() else playerInfoOrdering.sortedCopy( - mc.thePlayer.sendQueue.playerInfoMap - ) + + fun fetchTabEntries(): List<NetworkPlayerInfo> { + return if (mc.thePlayer == null) emptyList() + else playerInfoOrdering.sortedCopy(mc.thePlayer.sendQueue.playerInfoMap) + } /** * Sets a bunch of useful values based on the state of the scoreboard. Functionality is collected all into @@ -55,40 +53,43 @@ object TabListUtils { // exploFlag is just telling the loop that the next line is the relevant tab entry var exploFlag = false var numVisitorsFlag = false - // dungeonFlag keeps track of whether we've found the in-dungeons state. - val scoreboardList: List<String> = fetchTabEntries().mapNotNull { + + val scoreboardList = fetchTabEntries().mapNotNull { it.displayName?.unformattedText } for (line in scoreboardList) { + val trimmed = line.trim() when { - line.startsWith("Area: ") -> area = line.substring(6) - line == "Volcano Explosivity:" -> exploFlag = true + trimmed.contains(areaPattern) -> area = areaPattern.find(trimmed)!!.groupValues[1] + trimmed == "Volcano Explosivity:" -> exploFlag = true exploFlag -> { exploFlag = false - if (line != " INACTIVE") { - explosivity = true - } + explosivity = trimmed != "INACTIVE" } - line == " Dungeon Stats" -> { + + trimmed == "Dungeon Stats" -> { area = "Dungeon" } - line.startsWith(" Time Left:") -> { - emptyComposter = (line.substring(12) == "INACTIVE") + + trimmed.startsWith("Time Left: ") -> { + emptyComposter = trimmed.split(": ")[1] == "INACTIVE" } - line.startsWith(" Milestone") -> gardenMilestone = line.substring(1) - line.startsWith(" Next Visitor:") -> { - timeTillNextVisitor = line.substring(15) - maxVisitors = (timeTillNextVisitor == "Queue Full!") + + trimmed.startsWith("Milestone") -> gardenMilestone = trimmed + trimmed.contains(nextVisitorPattern) -> { + timeTillNextVisitor = nextVisitorPattern.find(trimmed)!!.groupValues[1] + maxVisitors = timeTillNextVisitor == "Queue Full!" } - line.startsWith("Visitors:") -> { - numVisitors = line.substring(11, 12).toInt() // TODO: FIX WHEN THEY ADD THE TENTH VISITOR + + trimmed.contains(visitorPattern) -> { + numVisitors = visitorPattern.find(trimmed)!!.groupValues[1].toInt() numVisitorsFlag = true } + line.contains("(Archer") -> { - val strArr = line.split(" ") - archerName = strArr[1] + archerName = line.split(" ")[1] } } } @@ -106,4 +107,6 @@ object TabListUtils { numVisitors = 0 } } + + private fun GameType.isSpectator() = this == GameType.SPECTATOR }
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/utils/WorldRenderUtils.kt b/src/main/kotlin/dulkirmod/utils/WorldRenderUtils.kt index 0728f38..7317d16 100644 --- a/src/main/kotlin/dulkirmod/utils/WorldRenderUtils.kt +++ b/src/main/kotlin/dulkirmod/utils/WorldRenderUtils.kt @@ -2,9 +2,8 @@ package dulkirmod.utils import dulkirmod.DulkirMod.Companion.mc import dulkirmod.mixins.AccessorRenderManager +import net.minecraft.client.gui.FontRenderer import net.minecraft.client.renderer.GlStateManager -import net.minecraft.client.renderer.GlStateManager.disableTexture2D -import net.minecraft.client.renderer.GlStateManager.enableTexture2D import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.entity.RenderManager @@ -14,180 +13,167 @@ import org.lwjgl.opengl.GL11 import java.awt.Color -class WorldRenderUtils { - - - companion object { - private val tessellator: Tessellator = Tessellator.getInstance() - private val worldRenderer: WorldRenderer = tessellator.worldRenderer - private val renderManager: RenderManager = mc.renderManager - fun renderString( - location: Vec3, - text: String, - depthTest: Boolean = true, - scale: Float = 1f, - showDistance: Boolean = false, - shadow: Boolean = false, - renderBlackBox: Boolean = true, - ) { - if (!depthTest) { - GL11.glDisable(GL11.GL_DEPTH_TEST) - GL11.glDepthMask(false) - } - GlStateManager.pushMatrix() - GlStateManager.enableBlend() - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) - GlStateManager.translate( - location.xCoord - mc.renderManager.viewerPosX, - location.yCoord - mc.renderManager.viewerPosY, - location.zCoord - mc.renderManager.viewerPosZ - ) - GlStateManager.color(1f, 1f, 1f, 0.5f) - GlStateManager.rotate(-mc.renderManager.playerViewY, 0.0f, 1.0f, 0.0f) - GlStateManager.rotate(mc.renderManager.playerViewX, 1.0f, 0.0f, 0.0f) - GlStateManager.scale(-scale / 25, -scale / 25, scale / 25) +object WorldRenderUtils { + private val tessellator: Tessellator + get() = Tessellator.getInstance() + private val worldRenderer: WorldRenderer + get() = tessellator.worldRenderer + private val renderManager: RenderManager + get() = mc.renderManager + private val fontRenderer: FontRenderer + get() = mc.fontRendererObj + + fun renderString( + location: Vec3, + text: String, + depthTest: Boolean = true, + scale: Float = 1f, + showDistance: Boolean = false, + shadow: Boolean = false, + renderBlackBox: Boolean = true, + ) { + if (!depthTest) { + GL11.glDisable(GL11.GL_DEPTH_TEST) + GL11.glDepthMask(false) + } + GlStateManager.pushMatrix() + GlStateManager.enableBlend() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.translate( + location.xCoord - renderManager.viewerPosX, + location.yCoord - renderManager.viewerPosY, + location.zCoord - renderManager.viewerPosZ + ) + GlStateManager.color(1f, 1f, 1f, 0.5f) + GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f) + GlStateManager.rotate(renderManager.playerViewX, 1.0f, 0.0f, 0.0f) + GlStateManager.scale(-scale / 25, -scale / 25, scale / 25) + + if (renderBlackBox) { + val j = fontRenderer.getStringWidth(text) / 2 + GlStateManager.disableTexture2D() + worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR) + worldRenderer.pos(-j - 1.0, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + worldRenderer.pos(-j - 1.0, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + worldRenderer.pos(j + 1.0, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + worldRenderer.pos(j + 1.0, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + tessellator.draw() + GlStateManager.enableTexture2D() + } + + if (shadow) { + fontRenderer.drawStringWithShadow(text, -fontRenderer.getStringWidth(text) / 2f, 0f, 0) + } else { + fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, 0, 0) + } + + // for waypoints + if (showDistance) { + val distance = "§e${mc.thePlayer.positionVector.distanceTo(location).toInt()}m" + GlStateManager.translate(0.0, 8.66, 0.0) + GlStateManager.scale(0.66, 0.66, 0.66) if (renderBlackBox) { - val j = mc.fontRendererObj.getStringWidth(text) / 2 - disableTexture2D() - val worldRenderer = Tessellator.getInstance().worldRenderer + val j = fontRenderer.getStringWidth(distance) / 2 + GlStateManager.disableTexture2D() worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR) - worldRenderer.pos((-j - 1).toDouble(), (-1).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() - worldRenderer.pos((-j - 1).toDouble(), 8.toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() - worldRenderer.pos((j + 1).toDouble(), 8.toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() - worldRenderer.pos((j + 1).toDouble(), (-1).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() - Tessellator.getInstance().draw() - enableTexture2D() + worldRenderer.pos(-j - 1.0, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + worldRenderer.pos(-j - 1.0, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + worldRenderer.pos(j + 1.0, 8.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + worldRenderer.pos(j + 1.0, -1.0, 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() + tessellator.draw() + GlStateManager.enableTexture2D() } if (shadow) { - mc.fontRendererObj.drawStringWithShadow( - text, - -mc.fontRendererObj.getStringWidth(text) / 2f, - 0f, - 0 - ) + fontRenderer.drawStringWithShadow(distance, -fontRenderer.getStringWidth(distance) / 2f, 0f, 0) } else { - mc.fontRendererObj.drawString( - text, - -mc.fontRendererObj.getStringWidth(text) / 2, - 0, - 0 - ) - } - - // for waypoints - if (showDistance) { - val distance = "§e${mc.thePlayer.positionVector.distanceTo(location).toInt()}m" - GlStateManager.translate(0.0, 8.66, 0.0) - GlStateManager.scale(.66, .66, .66) - - if (renderBlackBox) { - val j = mc.fontRendererObj.getStringWidth(distance) / 2 - disableTexture2D() - val worldRenderer = Tessellator.getInstance().worldRenderer - worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR) - worldRenderer.pos((-j - 1).toDouble(), (-1).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f) - .endVertex() - worldRenderer.pos((-j - 1).toDouble(), 8.toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() - worldRenderer.pos((j + 1).toDouble(), 8.toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex() - worldRenderer.pos((j + 1).toDouble(), (-1).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f) - .endVertex() - Tessellator.getInstance().draw() - enableTexture2D() - } - - if (shadow) { - mc.fontRendererObj.drawStringWithShadow( - distance, - -mc.fontRendererObj.getStringWidth(distance) / 2f, - 0f, - 0 - ) - } else { - mc.fontRendererObj.drawString( - distance, - -mc.fontRendererObj.getStringWidth(distance) / 2, - 0, - 0 - ) - } - } - - GlStateManager.color(1f, 1f, 1f) - GlStateManager.disableBlend() - GlStateManager.popMatrix() - if (!depthTest) { - GL11.glEnable(GL11.GL_DEPTH_TEST) - GL11.glDepthMask(true) + fontRenderer.drawString(distance, -fontRenderer.getStringWidth(distance) / 2, 0, 0) } } + GlStateManager.color(1f, 1f, 1f) + GlStateManager.disableBlend() + GlStateManager.popMatrix() + if (!depthTest) { + GL11.glEnable(GL11.GL_DEPTH_TEST) + GL11.glDepthMask(true) + } + } - /** - * Courtesy of Odin, I could not be bothered to deal with rendering code. - */ - fun drawCustomBox(x: Double, xWidth: Double, y: Double, yWidth: Double, z: Double, zWidth: Double, color: Color, thickness: Float = 3f, phase: Boolean) { - GlStateManager.pushMatrix() - - GlStateManager.color(color.red.toFloat() / 255f, color.green.toFloat() / 255f, color.blue.toFloat() / 255f, 1f) - GlStateManager.translate(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ) - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) - if (phase) GlStateManager.disableDepth() - disableTexture2D() - GlStateManager.disableLighting() - GlStateManager.enableBlend() - - GL11.glLineWidth(thickness) - - val x1 = x + xWidth - val y1 = y + yWidth - val z1 = z + zWidth - - worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION) - worldRenderer.pos(x1,y1,z1).endVertex() - worldRenderer.pos(x1,y1,z).endVertex() - worldRenderer.pos(x,y1,z).endVertex() - worldRenderer.pos(x,y1,z1).endVertex() - worldRenderer.pos(x1,y1,z1).endVertex() - worldRenderer.pos(x1,y,z1).endVertex() - worldRenderer.pos(x1,y,z).endVertex() - worldRenderer.pos(x,y,z).endVertex() - worldRenderer.pos(x,y,z1).endVertex() - worldRenderer.pos(x,y,z).endVertex() - worldRenderer.pos(x,y1,z).endVertex() - worldRenderer.pos(x,y,z).endVertex() - worldRenderer.pos(x1,y,z).endVertex() - worldRenderer.pos(x1,y1,z).endVertex() - worldRenderer.pos(x1,y,z).endVertex() - worldRenderer.pos(x1,y,z1).endVertex() - worldRenderer.pos(x,y,z1).endVertex() - worldRenderer.pos(x,y1,z1).endVertex() - worldRenderer.pos(x1,y1,z1).endVertex() - - tessellator.draw() - - enableTexture2D() - GlStateManager.disableBlend() - GlStateManager.enableDepth() - GlStateManager.popMatrix() - } + /** + * Courtesy of Odin, I could not be bothered to deal with rendering code. + */ + fun drawCustomBox( + x: Double, + xWidth: Double, + y: Double, + yWidth: Double, + z: Double, + zWidth: Double, + color: Color, + thickness: Float = 3f, + phase: Boolean + ) { + GlStateManager.pushMatrix() + + GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, 1f) + GlStateManager.translate(-renderManager.viewerPosX, -renderManager.viewerPosY, -renderManager.viewerPosZ) + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) + if (phase) GlStateManager.disableDepth() + GlStateManager.disableTexture2D() + GlStateManager.disableLighting() + GlStateManager.enableBlend() + + GL11.glLineWidth(thickness) + + val x1 = x + xWidth + val y1 = y + yWidth + val z1 = z + zWidth + + worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION) + worldRenderer.pos(x1, y1, z1).endVertex() + worldRenderer.pos(x1, y1, z).endVertex() + worldRenderer.pos(x, y1, z).endVertex() + worldRenderer.pos(x, y1, z1).endVertex() + worldRenderer.pos(x1, y1, z1).endVertex() + worldRenderer.pos(x1, y, z1).endVertex() + worldRenderer.pos(x1, y, z).endVertex() + worldRenderer.pos(x, y, z).endVertex() + worldRenderer.pos(x, y, z1).endVertex() + worldRenderer.pos(x, y, z).endVertex() + worldRenderer.pos(x, y1, z).endVertex() + worldRenderer.pos(x, y, z).endVertex() + worldRenderer.pos(x1, y, z).endVertex() + worldRenderer.pos(x1, y1, z).endVertex() + worldRenderer.pos(x1, y, z).endVertex() + worldRenderer.pos(x1, y, z1).endVertex() + worldRenderer.pos(x, y, z1).endVertex() + worldRenderer.pos(x, y1, z1).endVertex() + worldRenderer.pos(x1, y1, z1).endVertex() + + tessellator.draw() + + GlStateManager.enableTexture2D() + GlStateManager.disableBlend() + if (phase) GlStateManager.enableDepth() + GlStateManager.popMatrix() + } - private fun getRenderX() : Double { - return (mc.renderManager as AccessorRenderManager).renderX - } + private fun getRenderX(): Double { + return (mc.renderManager as AccessorRenderManager).renderX + } - private fun getRenderY() : Double { - return (mc.renderManager as AccessorRenderManager).renderY - } + private fun getRenderY(): Double { + return (mc.renderManager as AccessorRenderManager).renderY + } - private fun getRenderZ() : Double { - return (mc.renderManager as AccessorRenderManager).renderZ - } + private fun getRenderZ(): Double { + return (mc.renderManager as AccessorRenderManager).renderZ + } - fun fixRenderPos(x: Double, y: Double, z: Double) : Triple<Double, Double, Double> { - return Triple(x + getRenderX(), y + getRenderY(), z + getRenderZ()) - } + fun fixRenderPos(x: Double, y: Double, z: Double): Triple<Double, Double, Double> { + return Triple(x + getRenderX(), y + getRenderY(), z + getRenderZ()) } }
\ No newline at end of file diff --git a/src/main/resources/mixins.dulkirmod.json b/src/main/resources/mixins.dulkirmod.json index 6fe3635..a30c6d8 100644 --- a/src/main/resources/mixins.dulkirmod.json +++ b/src/main/resources/mixins.dulkirmod.json @@ -1,6 +1,6 @@ { - "minVersion": "0.6", "compatibilityLevel": "JAVA_8", + "minVersion": "0.8", "package": "dulkirmod.mixins", "refmap": "mixins.dulkirmod.refmap.json", "client": [ @@ -10,9 +10,7 @@ "MixinGuiScreen", "MixinItemRenderer", "MixinLayerArmorBase", - "MixinRenderManager" - ], - "mixins": [ + "MixinRenderManager", "MixinEntity", "MixinEntityLivingBase", "MixinGuiUtils", |