From 40a987d81a5aa3cc998d4079bd719c94ceec7757 Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Thu, 22 Jun 2023 20:47:36 +0100 Subject: [PATCH] Mixin Tessellator --- gradle.properties | 2 +- .../client/renderer/Tessellator.java | 182 ------- .../angelica/client/ShadersTess.java | 92 ++-- .../gtnewhorizons/angelica/mixins/Mixins.java | 3 +- .../early/renderer/MixinTessellator.java | 260 +++++++++ .../interfaces/TessellatorAccessor.java | 49 ++ .../angelica/transform/ACTTessellator.java | 509 ------------------ .../angelica/transform/AClassTransformer.java | 1 - src/main/resources/META-INF/angelica_at.cfg | 26 + 9 files changed, 391 insertions(+), 733 deletions(-) delete mode 100644 src/compileStubs/java/net/minecraft/client/renderer/Tessellator.java create mode 100644 src/main/java/com/gtnewhorizons/angelica/mixins/early/renderer/MixinTessellator.java create mode 100644 src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/TessellatorAccessor.java delete mode 100644 src/main/java/com/gtnewhorizons/angelica/transform/ACTTessellator.java create mode 100644 src/main/resources/META-INF/angelica_at.cfg diff --git a/gradle.properties b/gradle.properties index 845f08ac6..7369aafe4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -62,7 +62,7 @@ apiPackage = # Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/ # There can be multiple files in a comma-separated list. # Example value: mymodid_at.cfg,nei_at.cfg -accessTransformersFile = +accessTransformersFile = angelica_at.cfg # Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! usesMixins = true diff --git a/src/compileStubs/java/net/minecraft/client/renderer/Tessellator.java b/src/compileStubs/java/net/minecraft/client/renderer/Tessellator.java deleted file mode 100644 index 962280271..000000000 --- a/src/compileStubs/java/net/minecraft/client/renderer/Tessellator.java +++ /dev/null @@ -1,182 +0,0 @@ -package net.minecraft.client.renderer; - -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.ShortBuffer; - -import net.minecraft.client.shader.TesselatorVertexState; - -public class Tessellator { - - private static int nativeBufferSize; - private static int trivertsInBuffer; - public static boolean renderingWorldRenderer; - public boolean defaultTexture; - private int rawBufferSize; - public int textureID; - - /** The byte buffer used for GL allocation. */ - public ByteBuffer byteBuffer; - /** The same memory as byteBuffer, but referenced as an integer buffer. */ - public IntBuffer intBuffer; - /** The same memory as byteBuffer, but referenced as an float buffer. */ - public FloatBuffer floatBuffer; - /** The same memory as byteBuffer, but referenced as an short buffer. */ - public ShortBuffer shortBuffer; - /** Raw integer array. */ - public int[] rawBuffer; - /** The number of vertices to be drawn in the next draw call. Reset to 0 between draw calls. */ - public int vertexCount; - /** The first coordinate to be used for the texture. */ - public double textureU; - /** The second coordinate to be used for the texture. */ - public double textureV; - - public int brightness; - /** The color (RGBA) value to be used for the following draw call. */ - public int color; - /** Whether the current draw object for this tessellator has color values. */ - public boolean hasColor; - /** Whether the current draw object for this tessellator has texture coordinates. */ - public boolean hasTexture; - - public boolean hasBrightness; - /** Whether the current draw object for this tessellator has normal values. */ - public boolean hasNormals; - /** The index into the raw buffer to be used for the next data. */ - public int rawBufferIndex; - /** - * The number of vertices manually added to the given draw call. This differs from vertexCount because it adds extra - * vertices when converting quads to triangles. - */ - public int addedVertices; - /** Disables all color information for the following draw call. */ - public boolean isColorDisabled; - /** The draw mode currently being used by the tessellator. */ - public int drawMode; - /** An offset to be applied along the x-axis for all vertices in this draw call. */ - public double xOffset; - /** An offset to be applied along the y-axis for all vertices in this draw call. */ - public double yOffset; - /** An offset to be applied along the z-axis for all vertices in this draw call. */ - public double zOffset; - /** The normal to be applied to the face being drawn. */ - public int normal; - /** The static instance of the Tessellator. */ - public static final Tessellator instance = new Tessellator(); - /** Whether this tessellator is currently in draw mode. */ - public boolean isDrawing; - /** The size of the buffers used (in integers). */ - public int bufferSize; - - public float midTextureU; - public float midTextureV; - public float normalX; - public float normalY; - public float normalZ; - public float[] vertexPos = new float[16]; - - private Tessellator(int p_i1250_1_) {} - - public Tessellator() {} - - /** - * Draws the data set up in this tessellator and resets the state to prepare for new drawing. - */ - public int draw() { - return 0; - } - - public TesselatorVertexState getVertexState(float p_147564_1_, float p_147564_2_, float p_147564_3_) { - return null; - } - - public void setVertexState(TesselatorVertexState p_147565_1_) {} - - /** - * Clears the tessellator state in preparation for new drawing. - */ - public void reset() {} - - /** - * Sets draw mode in the tessellator to draw quads. - */ - public void startDrawingQuads() {} - - /** - * Resets tessellator state and prepares for drawing (with the specified draw mode). - */ - public void startDrawing(int p_78371_1_) {} - - /** - * Sets the texture coordinates. - */ - public void setTextureUV(double p_78385_1_, double p_78385_3_) {} - - public void setBrightness(int p_78380_1_) {} - - /** - * Sets the RGB values as specified, converting from floats between 0 and 1 to integers from 0-255. - */ - public void setColorOpaque_F(float p_78386_1_, float p_78386_2_, float p_78386_3_) {} - - /** - * Sets the RGBA values for the color, converting from floats between 0 and 1 to integers from 0-255. - */ - public void setColorRGBA_F(float p_78369_1_, float p_78369_2_, float p_78369_3_, float p_78369_4_) {} - - /** - * Sets the RGB values as specified, and sets alpha to opaque. - */ - public void setColorOpaque(int p_78376_1_, int p_78376_2_, int p_78376_3_) {} - - /** - * Sets the RGBA values for the color. Also clamps them to 0-255. - */ - public void setColorRGBA(int p_78370_1_, int p_78370_2_, int p_78370_3_, int p_78370_4_) {} - - public void func_154352_a(byte p_154352_1_, byte p_154352_2_, byte p_154352_3_) {} - - /** - * Adds a vertex specifying both x,y,z and the texture u,v for it. - */ - public void addVertexWithUV(double p_78374_1_, double p_78374_3_, double p_78374_5_, double p_78374_7_, - double p_78374_9_) {} - - /** - * Adds a vertex with the specified x,y,z to the current draw call. It will trigger a draw() if the buffer gets - * full. - */ - public void addVertex(double p_78377_1_, double p_78377_3_, double p_78377_5_) {} - - /** - * Sets the color to the given opaque value (stored as byte values packed in an integer). - */ - public void setColorOpaque_I(int p_78378_1_) {} - - /** - * Sets the color to the given color (packed as bytes in integer) and alpha values. - */ - public void setColorRGBA_I(int p_78384_1_, int p_78384_2_) {} - - /** - * Disables colors for the current draw call. - */ - public void disableColor() {} - - /** - * Sets the normal for the current draw call. - */ - public void setNormal(float p_78375_1_, float p_78375_2_, float p_78375_3_) {} - - /** - * Sets the translation for all vertices in the current draw call. - */ - public void setTranslation(double p_78373_1_, double p_78373_3_, double p_78373_5_) {} - - /** - * Offsets the translation for all vertices in the current draw call. - */ - public void addTranslation(float p_78372_1_, float p_78372_2_, float p_78372_3_) {} -} diff --git a/src/main/java/com/gtnewhorizons/angelica/client/ShadersTess.java b/src/main/java/com/gtnewhorizons/angelica/client/ShadersTess.java index 7ae6f387c..0cda7ff4d 100644 --- a/src/main/java/com/gtnewhorizons/angelica/client/ShadersTess.java +++ b/src/main/java/com/gtnewhorizons/angelica/client/ShadersTess.java @@ -14,6 +14,7 @@ import net.minecraft.client.renderer.Tessellator; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; +import com.gtnewhorizons.angelica.mixins.interfaces.TessellatorAccessor; import com.gtnewhorizons.angelica.transform.ALog; public class ShadersTess { @@ -21,6 +22,7 @@ public class ShadersTess { public static final int vertexStride = 16; public static int draw(Tessellator tess) { + final TessellatorAccessor tessa = (TessellatorAccessor) tess; if (!tess.isDrawing) { throw new IllegalStateException("Not tesselating!"); } else { @@ -32,40 +34,42 @@ public class ShadersTess { int realDrawMode = tess.drawMode; while (voffset < tess.vertexCount) { int vcount; - vcount = Math.min(tess.vertexCount - voffset, tess.byteBuffer.capacity() / (vertexStride * 4)); + vcount = Math.min( + tess.vertexCount - voffset, + tessa.getAngelica$byteBuffer().capacity() / (vertexStride * 4)); if (realDrawMode == GL11.GL_QUADS) vcount = vcount / 4 * 4; - tess.floatBuffer.clear(); - tess.shortBuffer.clear(); - tess.intBuffer.clear(); - tess.intBuffer.put(tess.rawBuffer, voffset * vertexStride, vcount * vertexStride); - tess.byteBuffer.position(0); - tess.byteBuffer.limit(vcount * (vertexStride * 4)); + tessa.getAngelica$floatBuffer().clear(); + tessa.getAngelica$shortBuffer().clear(); + tessa.getAngelica$intBuffer().clear(); + tessa.getAngelica$intBuffer().put(tess.rawBuffer, voffset * vertexStride, vcount * vertexStride); + tessa.getAngelica$byteBuffer().position(0); + tessa.getAngelica$byteBuffer().limit(vcount * (vertexStride * 4)); voffset += vcount; if (tess.hasTexture) { - tess.floatBuffer.position(3); - GL11.glTexCoordPointer(2, (vertexStride * 4), tess.floatBuffer); + tessa.getAngelica$floatBuffer().position(3); + GL11.glTexCoordPointer(2, (vertexStride * 4), tessa.getAngelica$floatBuffer()); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); } if (tess.hasBrightness) { OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); - tess.shortBuffer.position(6 * 2); - GL11.glTexCoordPointer(2, (vertexStride * 4), tess.shortBuffer); + tessa.getAngelica$shortBuffer().position(6 * 2); + GL11.glTexCoordPointer(2, (vertexStride * 4), tessa.getAngelica$shortBuffer()); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); } if (tess.hasColor) { - tess.byteBuffer.position(5 * 4); - GL11.glColorPointer(4, true, (vertexStride * 4), tess.byteBuffer); + tessa.getAngelica$byteBuffer().position(5 * 4); + GL11.glColorPointer(4, true, (vertexStride * 4), tessa.getAngelica$byteBuffer()); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); } if (tess.hasNormals) { - tess.floatBuffer.position(9); - GL11.glNormalPointer((vertexStride * 4), tess.floatBuffer); + tessa.getAngelica$floatBuffer().position(9); + GL11.glNormalPointer((vertexStride * 4), tessa.getAngelica$floatBuffer()); GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); } - tess.floatBuffer.position(0); - GL11.glVertexPointer(3, (vertexStride * 4), tess.floatBuffer); + tessa.getAngelica$floatBuffer().position(0); + GL11.glVertexPointer(3, (vertexStride * 4), tessa.getAngelica$floatBuffer()); ShadersTess.preDrawArray(tess); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); @@ -97,10 +101,11 @@ public class ShadersTess { } public static void preDrawArray(Tessellator tess) { + final TessellatorAccessor tessa = (TessellatorAccessor) tess; // Shaders.checkGLError("preDrawArray"); if (Shaders.useMultiTexCoord3Attrib && tess.hasTexture) { GL13.glClientActiveTexture(GL13.GL_TEXTURE3); - GL11.glTexCoordPointer(2, (vertexStride * 4), (FloatBuffer) tess.floatBuffer.position(12)); + GL11.glTexCoordPointer(2, (vertexStride * 4), (FloatBuffer) tessa.getAngelica$floatBuffer().position(12)); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL13.glClientActiveTexture(GL13.GL_TEXTURE0); } @@ -110,7 +115,7 @@ public class ShadersTess { 2, false, vertexStride * 4, - (FloatBuffer) tess.floatBuffer.position(12)); + (FloatBuffer) tessa.getAngelica$floatBuffer().position(12)); glEnableVertexAttribArrayARB(Shaders.midTexCoordAttrib); } if (Shaders.useEntityAttrib) { @@ -120,7 +125,7 @@ public class ShadersTess { false, false, vertexStride * 4, - (ShortBuffer) tess.shortBuffer.position(7 * 2)); + (ShortBuffer) tessa.getAngelica$shortBuffer().position(7 * 2)); glEnableVertexAttribArrayARB(Shaders.entityAttrib); } // Shaders.checkGLError("preDrawArray"); @@ -162,6 +167,7 @@ public class ShadersTess { } public static void addVertex(Tessellator tess, double parx, double pary, double parz) { + final TessellatorAccessor tessa = (TessellatorAccessor) (Object) tess; int[] rawBuffer = tess.rawBuffer; int rbi = tess.rawBufferIndex; float fx = (float) (parx + tess.xOffset); @@ -190,7 +196,7 @@ public class ShadersTess { // shaders mod calculate normal and mid UV if (tess.drawMode == 7) { int i = tess.addedVertices % 4; - float[] vertexPos = tess.vertexPos; + float[] vertexPos = tessa.getAngelica$vertexPos(); vertexPos[i * 4 + 0] = fx; vertexPos[i * 4 + 1] = fy; vertexPos[i * 4 + 2] = fz; @@ -207,26 +213,34 @@ public class ShadersTess { float vnz = x1 * y2 - x2 * y1; float lensq = vnx * vnx + vny * vny + vnz * vnz; float mult = (lensq != 0.0) ? (float) (1f / Math.sqrt(lensq)) : 1f; + float normalX = vnx * mult; + float normalY = vny * mult; + float normalZ = vnz * mult; + tessa.setAngelica$normalX(normalX); + tessa.setAngelica$normalY(normalY); + tessa.setAngelica$normalZ(normalZ); rawBuffer[rbi + (9 - vertexStride * 3)] = rawBuffer[rbi + (9 - vertexStride * 2)] = rawBuffer[rbi - + (9 - vertexStride * 1)] = Float.floatToRawIntBits(tess.normalX = vnx * mult); + + (9 - vertexStride * 1)] = Float.floatToRawIntBits(normalX); rawBuffer[rbi + (10 - vertexStride * 3)] = rawBuffer[rbi + (10 - vertexStride * 2)] = rawBuffer[rbi - + (10 - vertexStride * 1)] = Float.floatToRawIntBits(tess.normalY = vny * mult); + + (10 - vertexStride * 1)] = Float.floatToRawIntBits(normalY); rawBuffer[rbi + (11 - vertexStride * 3)] = rawBuffer[rbi + (11 - vertexStride * 2)] = rawBuffer[rbi - + (11 - vertexStride * 1)] = Float.floatToRawIntBits(tess.normalZ = vnz * mult); + + (11 - vertexStride * 1)] = Float.floatToRawIntBits(normalZ); tess.hasNormals = true; // mid UV - tess.midTextureU = (Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 3)]) - + Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 2)]) - + Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 1)]) - + (float) tess.textureU) / 4; - tess.midTextureV = (Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 3)]) - + Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 2)]) - + Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 1)]) - + (float) tess.textureV) / 4; + tessa.setAngelica$midTextureU( + (Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 3)]) + + Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 2)]) + + Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 1)]) + + (float) tess.textureU) / 4); + tessa.setAngelica$midTextureV( + (Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 3)]) + + Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 2)]) + + Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 1)]) + + (float) tess.textureV) / 4); rawBuffer[rbi + (12 - vertexStride * 3)] = rawBuffer[rbi + (12 - vertexStride * 2)] = rawBuffer[rbi - + (12 - vertexStride * 1)] = Float.floatToRawIntBits(tess.midTextureU); + + (12 - vertexStride * 1)] = Float.floatToRawIntBits(tessa.getAngelica$midTextureU()); rawBuffer[rbi + (13 - vertexStride * 3)] = rawBuffer[rbi + (13 - vertexStride * 2)] = rawBuffer[rbi - + (13 - vertexStride * 1)] = Float.floatToRawIntBits(tess.midTextureV); + + (13 - vertexStride * 1)] = Float.floatToRawIntBits(tessa.getAngelica$midTextureV()); } } // end normal and mid UV calculation @@ -241,11 +255,11 @@ public class ShadersTess { rawBuffer[rbi + 6] = tess.brightness; rawBuffer[rbi + 7] = Shaders.getEntityData(); rawBuffer[rbi + 8] = Shaders.getEntityData2(); - rawBuffer[rbi + 9] = Float.floatToRawIntBits((float) tess.normalX); - rawBuffer[rbi + 10] = Float.floatToRawIntBits((float) tess.normalY); - rawBuffer[rbi + 11] = Float.floatToRawIntBits((float) tess.normalZ); - rawBuffer[rbi + 12] = Float.floatToRawIntBits((float) tess.midTextureU); - rawBuffer[rbi + 13] = Float.floatToRawIntBits((float) tess.midTextureV); + rawBuffer[rbi + 9] = Float.floatToRawIntBits((float) tessa.getAngelica$normalX()); + rawBuffer[rbi + 10] = Float.floatToRawIntBits((float) tessa.getAngelica$normalY()); + rawBuffer[rbi + 11] = Float.floatToRawIntBits((float) tessa.getAngelica$normalZ()); + rawBuffer[rbi + 12] = Float.floatToRawIntBits((float) tessa.getAngelica$midTextureU()); + rawBuffer[rbi + 13] = Float.floatToRawIntBits((float) ((TessellatorAccessor) tess).getAngelica$midTextureV()); tess.rawBufferIndex = rbi += vertexStride; ++tess.vertexCount; diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java index 56eebc276..d9a7d9143 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java @@ -38,7 +38,8 @@ public enum Mixins { "renderer.MixinModelRenderer", "renderer.MixinTextureClock", "renderer.MixinTextureCompass", - "renderer.MixinSimpleTexture") + "renderer.MixinSimpleTexture", + "renderer.MixinTessellator") .setApplyIf(() -> true)) ; diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/renderer/MixinTessellator.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/renderer/MixinTessellator.java new file mode 100644 index 000000000..5d2b379be --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/renderer/MixinTessellator.java @@ -0,0 +1,260 @@ +package com.gtnewhorizons.angelica.mixins.early.renderer; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; +import java.util.PriorityQueue; + +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.shader.TesselatorVertexState; +import net.minecraft.client.util.QuadComparator; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.gtnewhorizons.angelica.client.ShadersTess; +import com.gtnewhorizons.angelica.mixins.interfaces.TessellatorAccessor; + +@Mixin(Tessellator.class) +public abstract class MixinTessellator implements TessellatorAccessor { + + @Shadow(remap = false) + public boolean defaultTexture; + @Shadow(remap = false) + private int rawBufferSize; + @Shadow(remap = false) + public int textureID; + @Shadow + public int[] rawBuffer; + @Shadow + public int vertexCount; + @Shadow + public int rawBufferIndex; + @Shadow + public int addedVertices; + @Shadow + public boolean hasTexture; + @Shadow + public boolean hasBrightness; + @Shadow + public boolean hasNormals; + @Shadow + public boolean hasColor; + @Shadow + public double xOffset; + @Shadow + public double yOffset; + @Shadow + public double zOffset; + private ByteBuffer angelica$byteBuffer; + private IntBuffer angelica$intBuffer; + private FloatBuffer angelica$floatBuffer; + private ShortBuffer angelica$shortBuffer; + public float[] angelica$vertexPos; + public float angelica$normalX; + public float angelica$normalY; + public float angelica$normalZ; + public float angelica$midTextureU; + public float angelica$midTextureV; + + @Inject(method = "(I)V", at = @At("TAIL")) + private void angelica$extendBufferConstructor(int bufferSize, CallbackInfo ci) { + angelica$byteBuffer = GLAllocation.createDirectByteBuffer(bufferSize * 4); + angelica$intBuffer = angelica$byteBuffer.asIntBuffer(); + angelica$floatBuffer = angelica$byteBuffer.asFloatBuffer(); + angelica$shortBuffer = angelica$byteBuffer.asShortBuffer(); + rawBuffer = new int[bufferSize]; + vertexCount = 0; + angelica$vertexPos = new float[16]; + } + + @Inject(method = "()V", at = @At("TAIL")) + private void angelica$extendEmptyConstructor(CallbackInfo ci) { + this.angelica$extendBufferConstructor(65536, null); + this.defaultTexture = false; + this.rawBufferSize = 0; + this.textureID = 0; + } + + /** + * @author eigenraven + * @reason The entire drawing process must be redirected to go through an alternative renderer + */ + @Overwrite + public int draw() { + return ShadersTess.draw((Tessellator) (Object) this); + } + + /** + * @author eigenraven + * @reason byteBuffer->angelica$byteBuffer + */ + @Overwrite + public void reset() { + this.vertexCount = 0; + this.angelica$byteBuffer.clear(); + this.rawBufferIndex = 0; + this.addedVertices = 0; + } + + /** + * @author eigenraven + * @reason The entire drawing process must be redirected to go through an alternative renderer + */ + @Overwrite + public void addVertex(double x, double y, double z) { + ShadersTess.addVertex((Tessellator) (Object) this, x, y, z); + } + + /** + * @author eigenraven + * @reason Modify 32->64, ModifyConstant causes an internal mixin crash in this method + */ + @Overwrite + public TesselatorVertexState getVertexState(float x, float y, float z) { + int[] tmpCopyBuffer = new int[this.rawBufferIndex]; + PriorityQueue pQueue = new PriorityQueue<>( + this.rawBufferIndex, + new QuadComparator( + this.rawBuffer, + x + (float) this.xOffset, + y + (float) this.yOffset, + z + (float) this.zOffset)); + byte batchSize = 64; + + for (int vidx = 0; vidx < this.rawBufferIndex; vidx += batchSize) { + pQueue.add(vidx); + } + + for (int batchVidx = 0; !pQueue.isEmpty(); batchVidx += batchSize) { + int queuedVidx = pQueue.remove(); + + for (int batchElement = 0; batchElement < batchSize; ++batchElement) { + tmpCopyBuffer[batchVidx + batchElement] = this.rawBuffer[queuedVidx + batchElement]; + } + } + + System.arraycopy(tmpCopyBuffer, 0, this.rawBuffer, 0, tmpCopyBuffer.length); + return new TesselatorVertexState( + tmpCopyBuffer, + this.rawBufferIndex, + this.vertexCount, + this.hasTexture, + this.hasBrightness, + this.hasNormals, + this.hasColor); + } + + @Inject(method = "setNormal(FFF)V", at = @At("HEAD")) + private void angelica$captureNormalComponents(float x, float y, float z, CallbackInfo ci) { + this.angelica$normalX = x; + this.angelica$normalY = y; + this.angelica$normalZ = z; + } + + @Override + public ByteBuffer getAngelica$byteBuffer() { + return angelica$byteBuffer; + } + + @Override + public IntBuffer getAngelica$intBuffer() { + return angelica$intBuffer; + } + + @Override + public FloatBuffer getAngelica$floatBuffer() { + return angelica$floatBuffer; + } + + @Override + public ShortBuffer getAngelica$shortBuffer() { + return angelica$shortBuffer; + } + + @Override + public float[] getAngelica$vertexPos() { + return angelica$vertexPos; + } + + @Override + public float getAngelica$normalX() { + return angelica$normalX; + } + + @Override + public float getAngelica$normalY() { + return angelica$normalY; + } + + @Override + public float getAngelica$normalZ() { + return angelica$normalZ; + } + + @Override + public float getAngelica$midTextureU() { + return angelica$midTextureU; + } + + @Override + public float getAngelica$midTextureV() { + return angelica$midTextureV; + } + + @Override + public void setAngelica$byteBuffer(ByteBuffer angelica$byteBuffer) { + this.angelica$byteBuffer = angelica$byteBuffer; + } + + @Override + public void setAngelica$intBuffer(IntBuffer angelica$intBuffer) { + this.angelica$intBuffer = angelica$intBuffer; + } + + @Override + public void setAngelica$floatBuffer(FloatBuffer angelica$floatBuffer) { + this.angelica$floatBuffer = angelica$floatBuffer; + } + + @Override + public void setAngelica$shortBuffer(ShortBuffer angelica$shortBuffer) { + this.angelica$shortBuffer = angelica$shortBuffer; + } + + @Override + public void setAngelica$vertexPos(float[] angelica$vertexPos) { + this.angelica$vertexPos = angelica$vertexPos; + } + + @Override + public void setAngelica$normalX(float angelica$normalX) { + this.angelica$normalX = angelica$normalX; + } + + @Override + public void setAngelica$normalY(float angelica$normalY) { + this.angelica$normalY = angelica$normalY; + } + + @Override + public void setAngelica$normalZ(float angelica$normalZ) { + this.angelica$normalZ = angelica$normalZ; + } + + @Override + public void setAngelica$midTextureU(float angelica$midTextureU) { + this.angelica$midTextureU = angelica$midTextureU; + } + + @Override + public void setAngelica$midTextureV(float angelica$midTextureV) { + this.angelica$midTextureV = angelica$midTextureV; + } +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/TessellatorAccessor.java b/src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/TessellatorAccessor.java new file mode 100644 index 000000000..053988604 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/interfaces/TessellatorAccessor.java @@ -0,0 +1,49 @@ +package com.gtnewhorizons.angelica.mixins.interfaces; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; + +public interface TessellatorAccessor { + + ByteBuffer getAngelica$byteBuffer(); + + IntBuffer getAngelica$intBuffer(); + + FloatBuffer getAngelica$floatBuffer(); + + ShortBuffer getAngelica$shortBuffer(); + + float[] getAngelica$vertexPos(); + + float getAngelica$normalX(); + + float getAngelica$normalY(); + + float getAngelica$normalZ(); + + float getAngelica$midTextureU(); + + float getAngelica$midTextureV(); + + void setAngelica$byteBuffer(ByteBuffer angelica$byteBuffer); + + void setAngelica$intBuffer(IntBuffer angelica$intBuffer); + + void setAngelica$floatBuffer(FloatBuffer angelica$floatBuffer); + + void setAngelica$shortBuffer(ShortBuffer angelica$shortBuffer); + + void setAngelica$vertexPos(float[] angelica$vertexPos); + + void setAngelica$normalX(float angelica$normalX); + + void setAngelica$normalY(float angelica$normalY); + + void setAngelica$normalZ(float angelica$normalZ); + + void setAngelica$midTextureU(float angelica$midTextureU); + + void setAngelica$midTextureV(float angelica$midTextureV); +} diff --git a/src/main/java/com/gtnewhorizons/angelica/transform/ACTTessellator.java b/src/main/java/com/gtnewhorizons/angelica/transform/ACTTessellator.java deleted file mode 100644 index 6ae5f5248..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/transform/ACTTessellator.java +++ /dev/null @@ -1,509 +0,0 @@ -package com.gtnewhorizons.angelica.transform; - -import static org.objectweb.asm.Opcodes.ACC_PRIVATE; -import static org.objectweb.asm.Opcodes.ACC_PROTECTED; -import static org.objectweb.asm.Opcodes.ACC_PUBLIC; -import static org.objectweb.asm.Opcodes.ACC_STATIC; -import static org.objectweb.asm.Opcodes.ACONST_NULL; -import static org.objectweb.asm.Opcodes.ALOAD; -import static org.objectweb.asm.Opcodes.BIPUSH; -import static org.objectweb.asm.Opcodes.DLOAD; -import static org.objectweb.asm.Opcodes.FLOAD; -import static org.objectweb.asm.Opcodes.GETFIELD; -import static org.objectweb.asm.Opcodes.GETSTATIC; -import static org.objectweb.asm.Opcodes.ICONST_0; -import static org.objectweb.asm.Opcodes.ICONST_1; -import static org.objectweb.asm.Opcodes.ICONST_4; -import static org.objectweb.asm.Opcodes.ILOAD; -import static org.objectweb.asm.Opcodes.IMUL; -import static org.objectweb.asm.Opcodes.INVOKESPECIAL; -import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; -import static org.objectweb.asm.Opcodes.IRETURN; -import static org.objectweb.asm.Opcodes.NEWARRAY; -import static org.objectweb.asm.Opcodes.POP; -import static org.objectweb.asm.Opcodes.PUTFIELD; -import static org.objectweb.asm.Opcodes.PUTSTATIC; -import static org.objectweb.asm.Opcodes.RETURN; -import static org.objectweb.asm.Opcodes.T_FLOAT; -import static org.objectweb.asm.Opcodes.T_INT; - -import net.minecraft.launchwrapper.IClassTransformer; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.FieldVisitor; -import org.objectweb.asm.Label; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; - -/** transformer for net.minecraft.client.renderer.Tessellator */ -public class ACTTessellator implements IClassTransformer { - - @Override - public byte[] transform(String par1, String par2, byte[] par3) { - ALog.fine("transforming %s %s", par1, par2); - ClassReader cr = new ClassReader(par3); - ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS); - CVTransform cv = new CVTransform(cw); - cr.accept(cv, 0); - return cw.toByteArray(); - } - - private static boolean inputHasStaticBuffer = false; - - private static class CVTransform extends ClassVisitor { - - String classname; - boolean endFields = false; - - public CVTransform(ClassVisitor cv) { - super(Opcodes.ASM4, cv); - } - - @Override - public void visit(int version, int access, String name, String signature, String superName, - String[] interfaces) { - classname = name; - // ALog.info(" class %s",name); - cv.visit(version, access, name, signature, superName, interfaces); - } - - @Override - public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { - // ALog.fine("%x %s %s %s",access,desc,name,nameM); - if (name.equals("vertexPos") || name.equals("normalX") - || name.equals("normalY") - || name.equals("normalZ") - || name.equals("midTextureU") - || name.equals("midTextureV")) { - return null; - } else if (((access & ACC_STATIC) != 0) - && (Names.tessellator_byteBuffer.name.equals(name) || Names.tessellator_intBuffer.name.equals(name) - || Names.tessellator_floatBuffer.name.equals(name) - || Names.tessellator_shortBuffer.name.equals(name) - || Names.tessellator_vertexCount.name.equals(name) - // nameM.equals(Names.Tessellator_useVBO) || - // nameM.equals(Names.Tessellator_vertexBuffers) - )) { - inputHasStaticBuffer = true; - // ALog.finest(" input has static buffer"); - access = access & (~ACC_STATIC & ~ACC_PRIVATE & ~ACC_PROTECTED) | ACC_PUBLIC; - } else { - access = access & (~ACC_PRIVATE & ~ACC_PROTECTED) | ACC_PUBLIC; - } - return cv.visitField(access, name, desc, signature, value); - } - - @Override - public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - if (!endFields) { - endFields = true; - FieldVisitor fv; - fv = cv.visitField(ACC_PUBLIC, "vertexPos", "[F", null, null); - fv.visitEnd(); - fv = cv.visitField(ACC_PUBLIC, "normalX", "F", null, null); - fv.visitEnd(); - fv = cv.visitField(ACC_PUBLIC, "normalY", "F", null, null); - fv.visitEnd(); - fv = cv.visitField(ACC_PUBLIC, "normalZ", "F", null, null); - fv.visitEnd(); - fv = cv.visitField(ACC_PUBLIC, "midTextureU", "F", null, null); - fv.visitEnd(); - fv = cv.visitField(ACC_PUBLIC, "midTextureV", "F", null, null); - fv.visitEnd(); - } - // ALog.fine(" method %s.%s%s = %s",classname,name,desc,nameM); - if (name.equals("")) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - return new MVclinit(cv.visitMethod(access, name, desc, signature, exceptions)); - } else if (name.equals("") && desc.equals("()V")) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - return new MVinit(cv.visitMethod(access, name, desc, signature, exceptions)); - } else if (name.equals("") && desc.equals("(I)V")) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - return new MVinitI(cv.visitMethod(access, name, desc, signature, exceptions)); - } else if (Names.tessellator_draw.equalsNameDesc(name, desc)) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - return new MVdraw(cv.visitMethod(access, name, desc, signature, exceptions)); - } else if (Names.tessellator_reset.equalsNameDesc(name, desc)) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - access = access & ~(ACC_PRIVATE | ACC_PROTECTED) | ACC_PUBLIC; - return new MVreset(cv.visitMethod(access, name, desc, signature, exceptions)); - } else if (Names.tessellator_addVertex.equalsNameDesc(name, desc)) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - return new MVaddVertex(cv.visitMethod(access, name, desc, signature, exceptions)); - } else if (Names.tessellator_setNormal.equalsNameDesc(name, desc)) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - return new MVsetNormal(cv.visitMethod(access, name, desc, signature, exceptions)); - } else if (Names.tessellator_sortQuad.equalsNameDesc(name, desc)) { - // ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,nameM); - return new MVsortQuad(cv.visitMethod(access, name, desc, signature, exceptions)); - } else { - access = access & ~(ACC_PRIVATE | ACC_PROTECTED) | ACC_PUBLIC; - } - return cv.visitMethod(access, name, desc, signature, exceptions); - } - } - - /* - * private static class MVclinit extends MethodVisitor { public MVclinit(MethodVisitor mv) { super(Opcodes.ASM4, - * mv); } } private static class MVinit extends MethodVisitor { public MVinit(MethodVisitor mv) { - * super(Opcodes.ASM4, mv); } - * @Override public void visitInsn(int opcode) { if (opcode == RETURN) { mv.visitVarInsn(ALOAD, 0); - * mv.visitIntInsn(BIPUSH, 16); mv.visitIntInsn(NEWARRAY, T_FLOAT); mv.visitFieldInsn(PUTFIELD, - * SMCNames.Tessellator_, "vertexPos", "[F"); } mv.visitInsn(opcode); } } - */ - - private static class MVclinit extends MethodVisitor { - - public MVclinit(MethodVisitor mv) { - super(Opcodes.ASM4, mv); - } - - @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - // ALog.finest(" F %d %s.%s %s", opcode, ownerM, nameM, descM); - if (opcode == PUTSTATIC && (Names.tessellator_byteBuffer.equals(owner, name) - || Names.tessellator_intBuffer.equals(owner, name) - || Names.tessellator_floatBuffer.equals(owner, name) - || Names.tessellator_shortBuffer.equals(owner, name) - || Names.tessellator_vertexCount.equals(owner, name) - // nameM.equals(Names.Tessellator_useVBO)|| - // nameM.equals(Names.Tessellator_vertexBuffers) - )) { - mv.visitInsn(POP); - return; - } else if (opcode == GETSTATIC && (Names.tessellator_byteBuffer.equals(owner, name) - // nameM.equals(Names.Tessellator_vertexBuffers) - )) { - mv.visitInsn(ACONST_NULL); - return; - // } else - // if (opcode==GETSTATIC && ( - // nameM.equals(Names.Tessellator_useVBO) - // )) - // { - // mv.visitInsn(ICONST_0); - // return; - } - mv.visitFieldInsn(opcode, owner, name, desc); - } - - @Override - public void visitMethodInsn(int opcode, String owner, String name, String desc) { - // ALog.finest(" M %d %s.%s %s", opcode, ownerM, nameM, descM); - if (Names.glAllocation_createDirectByteBuffer.equals(owner, name, desc)) { - mv.visitInsn(POP); - mv.visitInsn(ACONST_NULL); - return; - } else if (Names.glAllocation_createDirectIntBuffer.equals(owner, name, desc)) { - mv.visitInsn(POP); - mv.visitInsn(ACONST_NULL); - return; - } else - if (Names.equals("java/nio/ByteBuffer", "asIntBuffer", "()Ljava/nio/IntBuffer;", owner, name, desc)) { - mv.visitInsn(POP); - mv.visitInsn(ACONST_NULL); - return; - } else if (Names.equals( - "java/nio/ByteBuffer", - "asFloatBuffer", - "()Ljava/nio/FloatBuffer;", - owner, - name, - desc)) { - mv.visitInsn(POP); - mv.visitInsn(ACONST_NULL); - return; - } else - if (Names.equals( - "java/nio/ByteBuffer", - "asShortBuffer", - "()Ljava/nio/ShortBuffer;", - owner, - name, - desc)) { - mv.visitInsn(POP); - mv.visitInsn(ACONST_NULL); - return; - } - mv.visitMethodInsn(opcode, owner, name, desc); - } - } - - private static class MVinit extends MethodVisitor { - - public MVinit(MethodVisitor mv) { - super(Opcodes.ASM4, mv); - } - - @Override - public void visitMethodInsn(int opcode, String owner, String name, String desc) { - if (opcode == INVOKESPECIAL && Names.equals("java/lang/Object", "", "()V", owner, name, desc)) { - mv.visitLdcInsn(new Integer(65536)); - mv.visitMethodInsn(INVOKESPECIAL, Names.tessellator_.clas, "", "(I)V"); - return; - } - mv.visitMethodInsn(opcode, owner, name, desc); - } - } - - private static class MVinitI extends MethodVisitor { - - public MVinitI(MethodVisitor mv) { - super(Opcodes.ASM4, mv); - } - - @Override - public void visitInsn(int opcode) { - if (opcode == RETURN) { - if (inputHasStaticBuffer) { - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_4); - mv.visitInsn(IMUL); - mv.visitMethodInsn( - INVOKESTATIC, - Names.glAllocation_createDirectByteBuffer.clas, - Names.glAllocation_createDirectByteBuffer.name, - Names.glAllocation_createDirectByteBuffer.desc); - mv.visitFieldInsn( - PUTFIELD, - Names.tessellator_byteBuffer.clas, - Names.tessellator_byteBuffer.name, - Names.tessellator_byteBuffer.desc); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn( - GETFIELD, - Names.tessellator_byteBuffer.clas, - Names.tessellator_byteBuffer.name, - Names.tessellator_byteBuffer.desc); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/nio/ByteBuffer", "asIntBuffer", "()Ljava/nio/IntBuffer;"); - mv.visitFieldInsn( - PUTFIELD, - Names.tessellator_intBuffer.clas, - Names.tessellator_intBuffer.name, - Names.tessellator_intBuffer.desc); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn( - GETFIELD, - Names.tessellator_byteBuffer.clas, - Names.tessellator_byteBuffer.name, - Names.tessellator_byteBuffer.desc); - mv.visitMethodInsn( - INVOKEVIRTUAL, - "java/nio/ByteBuffer", - "asFloatBuffer", - "()Ljava/nio/FloatBuffer;"); - mv.visitFieldInsn( - PUTFIELD, - Names.tessellator_floatBuffer.clas, - Names.tessellator_floatBuffer.name, - Names.tessellator_floatBuffer.desc); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn( - GETFIELD, - Names.tessellator_byteBuffer.clas, - Names.tessellator_byteBuffer.name, - Names.tessellator_byteBuffer.desc); - mv.visitMethodInsn( - INVOKEVIRTUAL, - "java/nio/ByteBuffer", - "asShortBuffer", - "()Ljava/nio/ShortBuffer;"); - mv.visitFieldInsn( - PUTFIELD, - Names.tessellator_shortBuffer.clas, - Names.tessellator_shortBuffer.name, - Names.tessellator_shortBuffer.desc); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitIntInsn(NEWARRAY, T_INT); - mv.visitFieldInsn( - PUTFIELD, - Names.tessellator_rawBuffer.clas, - Names.tessellator_rawBuffer.name, - Names.tessellator_rawBuffer.desc); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ICONST_0); - mv.visitFieldInsn( - PUTFIELD, - Names.tessellator_vertexCount.clas, - Names.tessellator_vertexCount.name, - Names.tessellator_vertexCount.desc); - // mv.visitVarInsn(ALOAD, 0); - // mv.visitFieldInsn(GETSTATIC, Names.Tessellator_, Names.Tessellator_tryVBO, "Z"); - // Label l28 = new Label(); - // mv.visitJumpInsn(IFEQ, l28); - // mv.visitMethodInsn(INVOKESTATIC, "org/lwjgl/opengl/GLContext", "getCapabilities", - // "()Lorg/lwjgl/opengl/ContextCapabilities;"); - // mv.visitFieldInsn(GETFIELD, "org/lwjgl/opengl/ContextCapabilities", - // "GL_ARB_vertex_buffer_object", "Z"); - // mv.visitJumpInsn(IFEQ, l28); - // mv.visitInsn(ICONST_1); - // Label l29 = new Label(); - // mv.visitJumpInsn(GOTO, l29); - // mv.visitLabel(l28); - // mv.visitFrame(Opcodes.F_FULL, 2, new Object[] {Names.Tessellator_, Opcodes.INTEGER}, 1, new - // Object[] {Names.Tessellator_}); - // mv.visitInsn(ICONST_0); - // mv.visitLabel(l29); - // mv.visitFrame(Opcodes.F_FULL, 2, new Object[] {Names.Tessellator_, Opcodes.INTEGER}, 2, new - // Object[] {Names.Tessellator_, Opcodes.INTEGER}); - // mv.visitFieldInsn(PUTFIELD, Names.Tessellator_, Names.Tessellator_useVBO, "Z"); - // mv.visitVarInsn(ALOAD, 0); - // mv.visitFieldInsn(GETFIELD, Names.Tessellator_, Names.Tessellator_useVBO, "Z"); - // Label l31 = new Label(); - // mv.visitJumpInsn(IFEQ, l31); - // mv.visitVarInsn(ALOAD, 0); - // mv.visitVarInsn(ALOAD, 0); - // mv.visitFieldInsn(GETFIELD, Names.Tessellator_, Names.Tessellator_vboCount, "I"); - // mv.visitMethodInsn(INVOKESTATIC, Names.GLAllocation_, Names.GLAllocation_createDirectIntBuffer, - // Names.GLAllocation_createDirectIntBuffer_desc); - // mv.visitFieldInsn(PUTFIELD, Names.Tessellator_, Names.Tessellator_vertexBuffers, - // "Ljava/nio/IntBuffer;"); - // mv.visitVarInsn(ALOAD, 0); - // mv.visitFieldInsn(GETFIELD, Names.Tessellator_, Names.Tessellator_vertexBuffers, - // "Ljava/nio/IntBuffer;"); - // mv.visitMethodInsn(INVOKESTATIC, "org/lwjgl/opengl/ARBVertexBufferObject", "glGenBuffersARB", - // "(Ljava/nio/IntBuffer;)V"); - // mv.visitLabel(l31); - // mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); - } - mv.visitVarInsn(ALOAD, 0); - mv.visitIntInsn(BIPUSH, 16); - mv.visitIntInsn(NEWARRAY, T_FLOAT); - mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "vertexPos", "[F"); - } - mv.visitInsn(opcode); - } - } - - private static class MVdraw extends MethodVisitor { - - public MVdraw(MethodVisitor mv) { - super(Opcodes.ASM4, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(185, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn( - INVOKESTATIC, - "com/gtnewhorizons/angelica/client/ShadersTess", - "draw", - "(" + Names.tessellator_.desc + ")I"); - mv.visitInsn(IRETURN); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLocalVariable("this", Names.tessellator_.desc, null, l0, l1, 0); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - } - - private static class MVreset extends MethodVisitor { - - public MVreset(MethodVisitor mv) { - super(Opcodes.ASM4, mv); - } - - @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - // ALog.finest(" F %d %s.%s %s", opcode, ownerM, nameM, descM); - if (opcode == GETSTATIC && Names.tessellator_byteBuffer.equals(owner, name)) { - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, owner, name, desc); - return; - } - mv.visitFieldInsn(opcode, owner, name, desc); - } - } - - private static class MVaddVertex extends MethodVisitor { - - public MVaddVertex(MethodVisitor mv) { - super(Opcodes.ASM4, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(466, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(DLOAD, 1); - mv.visitVarInsn(DLOAD, 3); - mv.visitVarInsn(DLOAD, 5); - mv.visitMethodInsn( - INVOKESTATIC, - "com/gtnewhorizons/angelica/client/ShadersTess", - "addVertex", - "(" + Names.tessellator_.desc + "DDD)V"); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(467, l1); - mv.visitInsn(RETURN); - Label l2 = new Label(); - mv.visitLabel(l2); - mv.visitLocalVariable("this", Names.tessellator_.desc, null, l0, l2, 0); - mv.visitLocalVariable("par1", "D", null, l0, l2, 1); - mv.visitLocalVariable("par3", "D", null, l0, l2, 3); - mv.visitLocalVariable("par5", "D", null, l0, l2, 5); - mv.visitMaxs(7, 7); - mv.visitEnd(); - } - } - - private static class MVsetNormal extends MethodVisitor { - - public MVsetNormal(MethodVisitor mv) { - super(Opcodes.ASM4, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ICONST_1); - mv.visitFieldInsn( - PUTFIELD, - Names.tessellator_hasNormals.clas, - Names.tessellator_hasNormals.name, - Names.tessellator_hasNormals.desc); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(FLOAD, 1); - mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "normalX", "F"); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(FLOAD, 2); - mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "normalY", "F"); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(FLOAD, 3); - mv.visitFieldInsn(PUTFIELD, Names.tessellator_.clas, "normalZ", "F"); - mv.visitInsn(RETURN); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLocalVariable("this", Names.tessellator_.desc, null, l0, l5, 0); - mv.visitLocalVariable("par1", "F", null, l0, l5, 1); - mv.visitLocalVariable("par2", "F", null, l0, l5, 2); - mv.visitLocalVariable("par3", "F", null, l0, l5, 3); - mv.visitMaxs(2, 4); - mv.visitEnd(); - } - } - - private static class MVsortQuad extends MethodVisitor { - - public MVsortQuad(MethodVisitor mv) { - super(Opcodes.ASM4, mv); - } - - @Override - public void visitIntInsn(int opcode, int operand) { - if (opcode == BIPUSH && operand == 32) { - operand = 64; - } - super.visitIntInsn(opcode, operand); - } - } -} diff --git a/src/main/java/com/gtnewhorizons/angelica/transform/AClassTransformer.java b/src/main/java/com/gtnewhorizons/angelica/transform/AClassTransformer.java index d1a3e0bd6..1364c9f0e 100644 --- a/src/main/java/com/gtnewhorizons/angelica/transform/AClassTransformer.java +++ b/src/main/java/com/gtnewhorizons/angelica/transform/AClassTransformer.java @@ -24,7 +24,6 @@ public class AClassTransformer implements IClassTransformer { names = new Names(); InitNames.init(); ctMap = new HashMap(); - put(Names.tessellator_, new ACTTessellator()); put(Names.entityRenderer_, new ACTEntityRenderer()); put(Names.renderManager_, new ACTRenderManager()); put(Names.rendererLivingE_, new ACTRendererLivingEntity()); diff --git a/src/main/resources/META-INF/angelica_at.cfg b/src/main/resources/META-INF/angelica_at.cfg new file mode 100644 index 000000000..6417dab8c --- /dev/null +++ b/src/main/resources/META-INF/angelica_at.cfg @@ -0,0 +1,26 @@ +# Make all Tessellator fields public because using accessors for these would be too much rework right now +public net.minecraft.client.renderer.Tessellator field_78394_d # byteBuffer +public net.minecraft.client.renderer.Tessellator field_147568_c # intBuffer +public net.minecraft.client.renderer.Tessellator field_147566_d # floatBuffer +public net.minecraft.client.renderer.Tessellator field_147567_e # shortBuffer +public net.minecraft.client.renderer.Tessellator field_78405_h # rawBuffer +public net.minecraft.client.renderer.Tessellator field_78406_i # vertexCount +public net.minecraft.client.renderer.Tessellator field_78403_j # textureU +public net.minecraft.client.renderer.Tessellator field_78404_k # textureV +public net.minecraft.client.renderer.Tessellator field_78401_l # brightness +public net.minecraft.client.renderer.Tessellator field_78402_m # color +public net.minecraft.client.renderer.Tessellator field_78399_n # hasColor +public net.minecraft.client.renderer.Tessellator field_78400_o # hasTexture +public net.minecraft.client.renderer.Tessellator field_78414_p # hasBrightness +public net.minecraft.client.renderer.Tessellator field_78413_q # hasNormals +public net.minecraft.client.renderer.Tessellator field_147569_p # rawBufferIndex +public net.minecraft.client.renderer.Tessellator field_78411_s # addedVertices +public net.minecraft.client.renderer.Tessellator field_78410_t # isColorDisabled +public net.minecraft.client.renderer.Tessellator field_78409_u # drawMode +public net.minecraft.client.renderer.Tessellator field_78408_v # xOffset +public net.minecraft.client.renderer.Tessellator field_78407_w # yOffset +public net.minecraft.client.renderer.Tessellator field_78417_x # zOffset +public net.minecraft.client.renderer.Tessellator field_78416_y # normal +public net.minecraft.client.renderer.Tessellator field_78415_z # isDrawing +public net.minecraft.client.renderer.Tessellator field_78388_E # bufferSize +public net.minecraft.client.renderer.Tessellator func_78379_d()V # reset