aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-03-23 19:14:25 +0100
committerGitHub <noreply@github.com>2024-03-23 19:14:25 +0100
commit44014aa68a8c672c779f38202a215ab1e8dcd8c5 (patch)
tree08296df55bca53055497bb26253f24b1d7423c18 /src/main/java/at/hannibal2/skyhanni/utils
parent54aba6cbdd46da9f4c9d064382c0f487d06e3c0b (diff)
downloadskyhanni-44014aa68a8c672c779f38202a215ab1e8dcd8c5.tar.gz
skyhanni-44014aa68a8c672c779f38202a215ab1e8dcd8c5.tar.bz2
skyhanni-44014aa68a8c672c779f38202a215ab1e8dcd8c5.zip
Feature: Totem Of Corruption Overlay & Effective Area (#1139)
Co-authored-by: hannibal2 <24389977+hannibal002@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 53a228625..c253c91ee 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -702,6 +702,89 @@ object RenderUtils {
GlStateManager.popMatrix()
}
+ fun LorenzRenderWorldEvent.drawSphereInWorld(
+ color: Color,
+ location: LorenzVec,
+ radius: Float,
+ ) {
+ drawSphereInWorld(color, location.x, location.y, location.z, radius)
+ }
+
+ fun LorenzRenderWorldEvent.drawSphereInWorld(
+ color: Color,
+ x: Double,
+ y: Double,
+ z: Double,
+ radius: Float,
+ ) {
+ GlStateManager.pushMatrix()
+ GL11.glNormal3f(0.0f, 1.0f, 0.0f)
+
+ GlStateManager.enableDepth()
+ GlStateManager.enableBlend()
+ GlStateManager.depthFunc(GL11.GL_LEQUAL)
+ GlStateManager.disableCull()
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
+ GlStateManager.enableAlpha()
+ GlStateManager.disableTexture2D()
+ color.bindColor()
+
+ var x1 = x
+ var y1 = y
+ var z1 = z
+ val renderViewEntity = Minecraft.getMinecraft().renderViewEntity
+ val viewX =
+ renderViewEntity.prevPosX + (renderViewEntity.posX - renderViewEntity.prevPosX) * partialTicks.toDouble()
+ val viewY =
+ renderViewEntity.prevPosY + (renderViewEntity.posY - renderViewEntity.prevPosY) * partialTicks.toDouble()
+ val viewZ =
+ renderViewEntity.prevPosZ + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * partialTicks.toDouble()
+ x1 -= viewX
+ y1 -= viewY
+ z1 -= viewZ
+
+ val tessellator = Tessellator.getInstance()
+ val worldrenderer = tessellator.worldRenderer
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION)
+
+ val segments = 32
+
+ for (phi in 0 until segments) {
+ for (theta in 0 until segments * 2) {
+ val x2 = x1 + radius * sin(Math.PI * phi / segments) * cos(2.0 * Math.PI * theta / (segments * 2))
+ val y2 = y1 + radius * cos(Math.PI * phi / segments)
+ val z2 = z1 + radius * sin(Math.PI * phi / segments) * sin(2.0 * Math.PI * theta / (segments * 2))
+
+ val x3 = x1 + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * theta / (segments * 2))
+ val y3 = y1 + radius * cos(Math.PI * (phi + 1) / segments)
+ val z3 = z1 + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * theta / (segments * 2))
+
+ worldrenderer.pos(x2, y2, z2).endVertex()
+ worldrenderer.pos(x3, y3, z3).endVertex()
+
+ val x4 = x1 + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2))
+ val y4 = y1 + radius * cos(Math.PI * (phi + 1) / segments)
+ val z4 = z1 + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2))
+
+ val x5 = x1 + radius * sin(Math.PI * phi / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2))
+ val y5 = y1 + radius * cos(Math.PI * phi / segments)
+ val z5 = z1 + radius * sin(Math.PI * phi / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2))
+
+ worldrenderer.pos(x4, y4, z4).endVertex()
+ worldrenderer.pos(x5, y5, z5).endVertex()
+ }
+ }
+
+ tessellator.draw()
+
+ GlStateManager.enableCull()
+ GlStateManager.enableTexture2D()
+ GlStateManager.enableDepth()
+ GlStateManager.disableBlend()
+ GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f)
+ GlStateManager.popMatrix()
+ }
+
private fun Color.bindColor() =
GlStateManager.color(this.red / 255f, this.green / 255f, this.blue / 255f, this.alpha / 255f)