mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-22 21:29:44 +00:00
Mixin Tessellator
This commit is contained in:
1 parent
6840ff5c64
commit
40a987d81a
9 files changed
+391
-733
No files matched your search
@@ -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;
|
||||
|
||||
@@ -38,7 +38,8 @@ public enum Mixins {
|
||||
"renderer.MixinModelRenderer",
|
||||
"renderer.MixinTextureClock",
|
||||
"renderer.MixinTextureCompass",
|
||||
"renderer.MixinSimpleTexture")
|
||||
"renderer.MixinSimpleTexture",
|
||||
"renderer.MixinTessellator")
|
||||
.setApplyIf(() -> true))
|
||||
|
||||
;
|
||||
|
||||
@@ -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 = "<init>(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 = "<init>()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<Integer> 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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("<clinit>")) {
|
||||
// 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("<init>") && 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("<init>") && 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", "<init>", "()V", owner, name, desc)) {
|
||||
mv.visitLdcInsn(new Integer(65536));
|
||||
mv.visitMethodInsn(INVOKESPECIAL, Names.tessellator_.clas, "<init>", "(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user