From 9f1adbac1a07f0102e3ca1d477124f70473a9e33 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 10 Dec 2023 03:07:33 +0100 Subject: code cleanup --- .../rift/area/dreadfarm/WiltedBerberisConfig.java | 1 + .../area/dreadfarm/RiftWiltedBerberisHelper.kt | 1 - .../java/at/hannibal2/skyhanni/test/WorldEdit.kt | 33 +++--- .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 +- .../at/hannibal2/skyhanni/utils/RenderUtils.kt | 114 ++++++++++++--------- 5 files changed, 80 insertions(+), 71 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java index 9cad5a475..35a426b63 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/rift/area/dreadfarm/WiltedBerberisConfig.java @@ -21,6 +21,7 @@ public class WiltedBerberisConfig { @Expose @ConfigOption(name = "Hide Particles", desc = "Hide the Wilted Berberis particles.") @ConfigEditorBoolean + // TODO fix typo public boolean hideparticles = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt index aa1dafd55..d6764f199 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt @@ -99,7 +99,6 @@ class RiftWiltedBerberisHelper { } } - @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt b/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt index 3dced63f7..283698668 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt @@ -16,21 +16,19 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color object WorldEdit { - var leftPos = null as BlockPos? - var rightPos = null as BlockPos? + private var leftPos = null as BlockPos? + private var rightPos = null as BlockPos? - fun funAABB(left: BlockPos, right: BlockPos): AxisAlignedBB { - return AxisAlignedBB( - minOf(left.x, left.x + 1, right.x, right.x + 1).toDouble(), - minOf(left.y, left.y + 1, right.y, right.y + 1).toDouble(), - minOf(left.z, left.z + 1, right.z, right.z + 1).toDouble(), - maxOf(left.x, left.x + 1, right.x, right.x + 1).toDouble(), - maxOf(left.y, left.y + 1, right.y, right.y + 1).toDouble(), - maxOf(left.z, left.z + 1, right.z, right.z + 1).toDouble(), - ) - } + private fun funAABB(left: BlockPos, right: BlockPos) = AxisAlignedBB( + minOf(left.x, left.x + 1, right.x, right.x + 1).toDouble(), + minOf(left.y, left.y + 1, right.y, right.y + 1).toDouble(), + minOf(left.z, left.z + 1, right.z, right.z + 1).toDouble(), + maxOf(left.x, left.x + 1, right.x, right.x + 1).toDouble(), + maxOf(left.y, left.y + 1, right.y, right.y + 1).toDouble(), + maxOf(left.z, left.z + 1, right.z, right.z + 1).toDouble(), + ) - val aabb + private val aabb get() = leftPos?.let { l -> rightPos?.let { r -> funAABB(l, r) @@ -41,11 +39,11 @@ object WorldEdit { ClipboardUtils.copyToClipboard(generateCodeSnippet()) } - fun generateCodeSnippet(): String { + private fun generateCodeSnippet(): String { var text = "" - leftPos?.let { text += "val redLeft = net.minecraft.util.BlockPos(${it.x}, ${it.y}, ${it.z})\n" } - rightPos?.let { text += "val blueRight = net.minecraft.util.BlockPos(${it.x}, ${it.y}, ${it.z})\n" } - aabb?.let { text += "val aabb = net.minecraft.util.AxisAlignedBB(${it.minX}, ${it.minY}, ${it.minZ}, ${it.maxX}, ${it.maxY}, ${it.maxZ})\n" } + leftPos?.run { text += "val redLeft = net.minecraft.util.BlockPos($x, $y, $z)\n" } + rightPos?.run { text += "val blueRight = net.minecraft.util.BlockPos($x, $y, $z)\n" } + aabb?.run { text += "val aabb = net.minecraft.util.AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ)\n" } return text } @@ -59,7 +57,6 @@ object WorldEdit { } } - @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { leftPos = null diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 2724d40e5..190d093a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -634,7 +634,7 @@ object LorenzUtils { enumValueOfOrNull(name) ?: kotlin.error("Unknown enum constant for ${enumValues().first().name.javaClass.simpleName}: '$name'") - fun isInDevEnviromen() = Launch.blackboard.get("fml.deobfuscatedEnvironment") as Boolean + fun isInDevEnviromen() = Launch.blackboard["fml.deobfuscatedEnvironment"] as Boolean fun shutdownMinecraft(reason: String? = null) { System.err.println("SkyHanni-${SkyHanniMod.version} forced the game to shutdown.") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 60beaf029..b7bbf9487 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -858,10 +858,9 @@ object RenderUtils { drawFilledBoundingBox_nea(aabb, c, alphaMultiplier, renderRelativeToCamera, drawVerticalBarriers, partialTicks) } - fun drawWireframeBoundingBox_nea( aabb: AxisAlignedBB, - c: Color, + color: Color, partialTicks: Float, ) { GlStateManager.enableBlend() @@ -877,37 +876,45 @@ object RenderUtils { val tessellator = Tessellator.getInstance() val worldRenderer = tessellator.worldRenderer - GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f) + with(color) { + GlStateManager.color(red / 255f, green / 255f, blue / 255f, alpha / 255f) + } // Bottom face worldRenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, minY, minZ).endVertex() + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + worldRenderer.pos(minX, minY, maxZ).endVertex() + } tessellator.draw() // Top face worldRenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() + worldRenderer.pos(minX, maxY, minZ).endVertex() + } tessellator.draw() worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, minY, minZ).endVertex() + worldRenderer.pos(minX, maxY, minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(minX, minY, maxZ).endVertex() + worldRenderer.pos(minX, maxY, maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + } tessellator.draw() @@ -916,7 +923,6 @@ object RenderUtils { GlStateManager.disableBlend() } - fun drawFilledBoundingBox_nea( aabb: AxisAlignedBB, c: Color, @@ -951,17 +957,19 @@ object RenderUtils { if (drawVerticalBarriers) { GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier) worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - tessellator.draw() - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - tessellator.draw() + with(effectiveAABB) { + worldRenderer.pos(minX, minY, minZ).endVertex() + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + worldRenderer.pos(minX, minY, maxZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(minX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() + worldRenderer.pos(minX, maxY, minZ).endVertex() + tessellator.draw() + } } GlStateManager.color( c.red / 255f * 0.8f, @@ -972,16 +980,18 @@ object RenderUtils { //x worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - tessellator.draw() - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, minY, maxZ).endVertex() + worldRenderer.pos(minX, maxY, maxZ).endVertex() + worldRenderer.pos(minX, maxY, minZ).endVertex() + worldRenderer.pos(minX, minY, minZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + } tessellator.draw() GlStateManager.color( c.red / 255f * 0.9f, @@ -991,16 +1001,18 @@ object RenderUtils { ) //z worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() - tessellator.draw() - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() - worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + with(effectiveAABB) { + worldRenderer.pos(minX, maxY, minZ).endVertex() + worldRenderer.pos(maxX, maxY, minZ).endVertex() + worldRenderer.pos(maxX, minY, minZ).endVertex() + worldRenderer.pos(minX, minY, minZ).endVertex() + tessellator.draw() + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) + worldRenderer.pos(minX, minY, maxZ).endVertex() + worldRenderer.pos(maxX, minY, maxZ).endVertex() + worldRenderer.pos(maxX, maxY, maxZ).endVertex() + worldRenderer.pos(minX, maxY, maxZ).endVertex() + } tessellator.draw() GlStateManager.enableTexture2D() GlStateManager.enableCull() -- cgit