From 2942b2fd7ba5b62aa0d5ef3622bccaf05954d2cd Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Tue, 11 Jul 2023 11:20:28 -0400 Subject: [PATCH] =?UTF-8?q?I=20mean...=20It=20kinda=20works...=20=C2=AF\?= =?UTF-8?q?=5F(=E3=83=84)=5F/=C2=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Shape Renderer is fucked up but it still works... kinda --- .../minecraft/render/ShapeRenderer.java | 65 +++++++++++-------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/mojang/minecraft/render/ShapeRenderer.java b/src/main/java/com/mojang/minecraft/render/ShapeRenderer.java index 1a484dc..d507199 100644 --- a/src/main/java/com/mojang/minecraft/render/ShapeRenderer.java +++ b/src/main/java/com/mojang/minecraft/render/ShapeRenderer.java @@ -16,6 +16,8 @@ public final class ShapeRenderer { private float b; private boolean color = false; private boolean texture = false; + private boolean normals = false; + private int normal; private int vertexLength = 3; private int length = 0; private boolean noColor = false; @@ -23,41 +25,37 @@ public final class ShapeRenderer { public final void end() { - if(this.vertices > 0) { this.buffer.clear(); this.buffer.put(this.data, 0, this.length); this.buffer.flip(); - if(this.texture && this.color) { - GL11.glInterleavedArrays(10794, 0, this.buffer); - } else if(this.texture) { - GL11.glInterleavedArrays(10791, 0, this.buffer); - } else if(this.color) { - GL11.glInterleavedArrays(10788, 0, this.buffer); - } else { - GL11.glInterleavedArrays(10785, 0, this.buffer); + + if (this.texture) { + GL11.glEnableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); + } + + if (this.color) { + GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY); + } + + if (this.normals) { + GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY); + } + + GL11._wglDrawArrays(7, 0, this.vertices); + + if (this.texture) { + GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY); } - GL11.glEnableClientState('\u8074'); - if(this.texture) { - GL11.glEnableClientState('\u8078'); + if (this.color) { + GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY); } - if(this.color) { - GL11.glEnableClientState('\u8076'); + if (this.normals) { + GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY); } - - GL11.glDrawArrays(7, 0, this.vertices); - GL11.glDisableClientState('\u8074'); - if(this.texture) { - GL11.glDisableClientState('\u8078'); - } - - if(this.color) { - GL11.glDisableClientState('\u8076'); - } - } - - this.clear(); + + this.clear(); } private void clear() { @@ -68,6 +66,7 @@ public final class ShapeRenderer { public final void begin() { this.clear(); + this.normals = false; this.color = false; this.texture = false; this.noColor = false; @@ -108,6 +107,10 @@ public final class ShapeRenderer { this.data[this.length++] = this.g; this.data[this.length++] = this.b; } + + if(this.normals) { + this.data[this.length++] = this.normal; + } this.data[this.length++] = var1; this.data[this.length++] = var2; @@ -151,7 +154,13 @@ public final class ShapeRenderer { } public final void normal(float var1, float var2, float var3) { - GL11.glNormal3f(var1, var2, var3); + this.normals = true; + float len = (float) Math.sqrt(var1 * var1 + var2 * var2 + var3 * var3); + int var4 = (int) ((var1 / len) * 127.0F) + 127; + int var5 = (int) ((var2 / len) * 127.0F) + 127; + int var6 = (int) ((var3 / len) * 127.0F) + 127; + this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16; + GL11.glNormal3f(var1, var2, var3); } }