diff options
author | Linnea Gräf <nea@nea.moe> | 2023-12-10 03:06:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-10 03:06:15 +0100 |
commit | b01af78657ee336c3ebacacb4d6b11699ec0b957 (patch) | |
tree | 749de38ea72472d7198b7f2ddf61989bdd9e477d /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 61368c57bd36f3d6be3d072cfd9bbb24ca8fa090 (diff) | |
download | skyhanni-b01af78657ee336c3ebacacb4d6b11699ec0b957.tar.gz skyhanni-b01af78657ee336c3ebacacb4d6b11699ec0b957.tar.bz2 skyhanni-b01af78657ee336c3ebacacb4d6b11699ec0b957.zip |
Add region selector (#732)
Added WorldEdit region selection preview support. #732
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt | 7 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 59 |
2 files changed, 64 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index b3cd44032..2a35a488a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -23,7 +23,9 @@ data class LorenzVec( constructor(x: Float, y: Float, z: Float) : this(x.toDouble(), y.toDouble(), z.toDouble()) - fun toBlocPos(): BlockPos = BlockPos(x, y, z) + @Deprecated("Misspelled function name", replaceWith = ReplaceWith("toBlockPos()")) + fun toBlocPos(): BlockPos = toBlockPos() + fun toBlockPos(): BlockPos = BlockPos(x, y, z) fun toVec3(): Vec3 = Vec3(x, y, z) @@ -48,7 +50,8 @@ data class LorenzVec( return (dx * dx + dz * dz) } - fun add(x: Double = 0.0, y: Double = 0.0, z: Double = 0.0): LorenzVec = LorenzVec(this.x + x, this.y + y, this.z + z) + fun add(x: Double = 0.0, y: Double = 0.0, z: Double = 0.0): LorenzVec = + LorenzVec(this.x + x, this.y + y, this.z + z) fun add(x: Int = 0, y: Int = 0, z: Int = 0): LorenzVec = LorenzVec(this.x + x, this.y + y, this.z + z) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index f9e2b7cdf..60beaf029 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -858,6 +858,65 @@ object RenderUtils { drawFilledBoundingBox_nea(aabb, c, alphaMultiplier, renderRelativeToCamera, drawVerticalBarriers, partialTicks) } + + fun drawWireframeBoundingBox_nea( + aabb: AxisAlignedBB, + c: Color, + partialTicks: Float, + ) { + GlStateManager.enableBlend() + GlStateManager.disableLighting() + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) + GlStateManager.disableTexture2D() + GlStateManager.disableCull() + val vp = getViewerPos(partialTicks) + val effectiveAABB = AxisAlignedBB( + aabb.minX - vp.x, aabb.minY - vp.y, aabb.minZ - vp.z, + aabb.maxX - vp.x, aabb.maxY - vp.y, aabb.maxZ - vp.z, + ) + val tessellator = Tessellator.getInstance() + val worldRenderer = tessellator.worldRenderer + + GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.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() + 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() + 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() + + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.minX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.minZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.minZ).endVertex() + + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.minY, effectiveAABB.maxZ).endVertex() + worldRenderer.pos(effectiveAABB.maxX, effectiveAABB.maxY, effectiveAABB.maxZ).endVertex() + + tessellator.draw() + + GlStateManager.enableTexture2D() + GlStateManager.enableCull() + GlStateManager.disableBlend() + } + + fun drawFilledBoundingBox_nea( aabb: AxisAlignedBB, c: Color, |