Renderer Mixins & Lighting Level Mixins

This commit is contained in:
Jason Mitchell committed 2023-02-24 17:57:09 -08:00
1 parent df3ff717f0
commit 39e7b5b3ea
10 files changed
+217 -461

No files matched your search

@@ -14,7 +14,14 @@ public enum Mixins {
.setPhase(Phase.EARLY).addMixinClasses("StartShaders.MixinMinecraft").setApplyIf(() -> true)),
ANGELICA_SHADERS_BUTTON(new Builder("Add Shaders Button").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).addMixinClasses("ShadersButton.MixinGuiVideoSettings").setApplyIf(() -> true))
.setPhase(Phase.EARLY).addMixinClasses("ShadersButton.MixinGuiVideoSettings").setApplyIf(() -> true)),
ANGELICA_LIGHTING(
new Builder("Lighting").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT).setPhase(Phase.EARLY)
.addMixinClasses("Lighting.MixinBlock", "Lighting.MixinRenderBlocks").setApplyIf(() -> true)),
ANGELICA_RENDERER(new Builder("Renderer").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).addMixinClasses("Renderer.MixinRenderBlocks").setApplyIf(() -> true))
;
@@ -0,0 +1,21 @@
package com.gtnewhorizons.angelica.mixins.early.Lighting;
import net.minecraft.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(Block.class)
public class MixinBlock {
@ModifyConstant(
method = "Lnet/minecraft/block/Block;getAmbientOcclusionLightValue()F",
constant = @Constant(floatValue = 0.2f))
public float angelica$blockAoLight(float constant) {
return Shaders.blockAoLight;
}
}
@@ -0,0 +1,112 @@
package com.gtnewhorizons.angelica.mixins.early.Lighting;
import net.minecraft.client.renderer.RenderBlocks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Slice;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(RenderBlocks.class)
public class MixinRenderBlocks {
// All of these expect 1 replacement only
@ModifyConstant(
method = { "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockBed(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockDoor(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockLiquid(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockCactusImpl(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithColorMultiplier(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockSandFalling(Lnet/minecraft/block/Block;Lnet/minecraft/world/World;IIII)V" },
constant = @Constant(floatValue = 0.5F),
expect = 1)
public float angelica$blockSingleLightLevel05(float constant) {
return Shaders.blockLightLevel05;
}
@ModifyConstant(
method = { "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockBed(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockLiquid(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockDoor(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockCactusImpl(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithColorMultiplier(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockSandFalling(Lnet/minecraft/block/Block;Lnet/minecraft/world/World;IIII)V" },
constant = @Constant(floatValue = 0.6F),
expect = 1)
public float angelica$blockSingleLightLevel06(float constant) {
return Shaders.blockLightLevel06;
}
@ModifyConstant(
method = { "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockBed(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockLiquid(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockDoor(Lnet/minecraft/block/Block;III)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockCactusImpl(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithColorMultiplier(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderBlockSandFalling(Lnet/minecraft/block/Block;Lnet/minecraft/world/World;IIII)V" },
constant = @Constant(floatValue = 0.8F),
expect = 1)
public float angelica$blockSingleLightLevel08(float constant) {
return Shaders.blockLightLevel08;
}
// Piston Extension - Differing expectations, and slicing required
@ModifyConstant(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderPistonExtension(Lnet/minecraft/block/Block;IIIZ)Z",
constant = @Constant(floatValue = 0.5F),
expect = 3,
slice = @Slice(from = @At(value = "CONSTANT", args = "doubleValue=8.0D", ordinal = 0)))
public float angelica$pistonBlockLightLevel05(float constant) {
return Shaders.blockLightLevel05;
}
@ModifyConstant(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderPistonExtension(Lnet/minecraft/block/Block;IIIZ)Z",
constant = @Constant(floatValue = 0.6F),
expect = 12)
public float angelica$pistonBlockLightLevel06(float constant) {
return Shaders.blockLightLevel06;
}
@ModifyConstant(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderPistonExtension(Lnet/minecraft/block/Block;IIIZ)Z",
constant = @Constant(floatValue = 0.8F),
expect = 4)
public float angelica$pistonBlockLightLevel08(float constant) {
return Shaders.blockLightLevel08;
}
// BlockWithAmbientOcclusion
@ModifyConstant(
method = {
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithAmbientOcclusionPartial(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithAmbientOcclusion(Lnet/minecraft/block/Block;IIIFFF)Z" },
constant = @Constant(floatValue = 0.5F))
public float angelica$multipleBlockLightLevel05(float constant) {
return Shaders.blockLightLevel05;
}
@ModifyConstant(
method = {
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithAmbientOcclusionPartial(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithAmbientOcclusion(Lnet/minecraft/block/Block;IIIFFF)Z" },
constant = @Constant(floatValue = 0.6F))
public float angelica$multipleBlockLightLevel06(float constant) {
return Shaders.blockLightLevel06;
}
@ModifyConstant(
method = {
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithAmbientOcclusionPartial(Lnet/minecraft/block/Block;IIIFFF)Z",
"Lnet/minecraft/client/renderer/RenderBlocks;renderStandardBlockWithAmbientOcclusion(Lnet/minecraft/block/Block;IIIFFF)Z" },
constant = @Constant(floatValue = 0.8F))
public float angelica$multipleBlockLightLevel08(float constant) {
return Shaders.blockLightLevel08;
}
}
@@ -0,0 +1,76 @@
package com.gtnewhorizons.angelica.mixins.early.Renderer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlowerPot;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.Item;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.gtnewhorizon.mixinextras.injector.wrapoperation.Operation;
import com.gtnewhorizon.mixinextras.injector.wrapoperation.WrapOperation;
import com.gtnewhorizons.angelica.client.Shaders;
@Mixin(RenderBlocks.class)
public class MixinRenderBlocks {
// Block
@Inject(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockByRenderType(Lnet/minecraft/block/Block;III)Z",
at = @At("HEAD"))
private void angelica$injectShadersBlockPushEntity(Block block, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.pushEntity((RenderBlocks) ((Object) this), block, x, y, z);
}
@Inject(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockByRenderType(Lnet/minecraft/block/Block;III)Z",
at = @At("RETURN"))
private void angelica$injectShadersPopEntityBlock(Block block, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.popEntity();
}
// BlockFlowerPot
@Inject(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z",
at = @At("HEAD"))
private void angelica$injectShadersFlowerpotPushEntity(BlockFlowerPot blockFlowerPot, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.pushEntity((RenderBlocks) ((Object) this), blockFlowerPot, x, y, z);
}
@Inject(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z",
at = @At("RETURN"))
private void angelica$injectShadersFlowerpotPopEntity(BlockFlowerPot blockFlowerPot, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.popEntity();
}
@WrapOperation(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/Block;getBlockFromItem(Lnet/minecraft/item/Item;)Lnet/minecraft/block/Block;"))
private Block angelica$injectShadersFlowerpotItemBlockPushEntity(Item itemIn, Operation<Block> original) {
final Block block = original.call(itemIn);
Shaders.pushEntity(block);
return block;
}
@Inject(
method = "Lnet/minecraft/client/renderer/RenderBlocks;renderBlockFlowerpot(Lnet/minecraft/block/BlockFlowerPot;III)Z",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/Tessellator;addTranslation(FFF)V",
shift = At.Shift.AFTER,
ordinal = 1))
private void angelica$injectShadersFlowerpotItemBlockPopEntity(BlockFlowerPot blockFlowerPot, int x, int y, int z,
CallbackInfoReturnable<Boolean> cir) {
Shaders.popEntity();
}
}
@@ -1,69 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ACTBlock 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, 0);
CVTransform cv = new CVTransform(cw);
cr.accept(cv, 0);
return cw.toByteArray();
}
private static class CVTransform extends ClassVisitor {
String classname;
public CVTransform(ClassVisitor cv) {
super(Opcodes.ASM4, cv);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
this.classname = name;
// ALog.info(" class %s",name);
super.visit(version, access, name, signature, superName, interfaces);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (Names.block_getAoLight.equalsNameDesc(name, desc)) {
// ALog.info(" patching");
return new MVgetAoLight(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVgetAoLight extends MethodVisitor {
public MVgetAoLight(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
@Override
public void visitLdcInsn(Object cst) {
if (cst instanceof Float) {
if (((Float) cst).floatValue() == 0.2f) {
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", "blockAoLight", "F");
ALog.info(" blockAoLight");
return;
}
}
mv.visitLdcInsn(cst);
}
}
}
@@ -1,386 +0,0 @@
package com.gtnewhorizons.angelica.transform;
import static org.objectweb.asm.Opcodes.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodNode;
public class ACTRenderBlocks 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 class CVTransform extends ClassVisitor {
String classname;
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 MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
// ALog.info(" method %s.%s%s = %s",classname,name,desc,remappedName);
if (Names.renderBlocks_renderBlockByRenderType.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkByRenType(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderBlocks_renderBlockFlowerPot.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkFlowerPot(cv.visitMethod(access, name, desc, signature, exceptions));
} else if (Names.renderBlocks_renderStdBlockWithAOP.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderStdBlockWithAO.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkWithAO(
access,
name,
desc,
signature,
exceptions,
cv.visitMethod(access, name, desc, signature, exceptions));
} else
if (Names.renderBlocks_renderStdBlockWithCM.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockCactusImpl.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockBed.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockFluids.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockDoor.equalsNameDesc(name, desc)
|| Names.renderBlocks_renderBlockSandFalling.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkFVar(cv.visitMethod(access, name, desc, signature, exceptions));
} else
if (Names.renderBlocks_renderPistonExtension.equalsNameDesc(name, desc)) {
// ALog.finer(" patching method %s.%s%s = %s",classname,name,desc,remappedName);
return new MVrenBlkPistonExt(cv.visitMethod(access, name, desc, signature, exceptions));
}
return cv.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class MVrenBlkByRenType extends MethodVisitor {
public MVrenBlkByRenType(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int nPatch = 0;
@Override
public void visitCode() {
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 3);
mv.visitVarInsn(ILOAD, 4);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"pushEntity",
"(" + Names.renderBlocks_.desc + Names.block_.desc + "III)V");
// ALog.info(" pushEntity");
++nPatch;
}
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.IRETURN) {
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "popEntity", "()V");
// ALog.info(" popEntity");
++nPatch;
}
mv.visitInsn(opcode);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
private static class MVrenBlkFlowerPot extends MethodVisitor {
public MVrenBlkFlowerPot(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int nPatch = 0;
int state = 0;
@Override
public void visitVarInsn(int opcode, int var) {
super.visitVarInsn(opcode, var);
if (state == 1) {
++state;
mv.visitVarInsn(ALOAD, var);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"pushEntity",
"(" + Names.block_.desc + ")V");
}
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
super.visitMethodInsn(opcode, owner, name, desc);
switch (state) {
case 0:
if (Names.block_getBlockFromItem.equals(owner, name, desc)) {
++state;
}
break;
case 2:
if (Names.tessellator_addTranslation.equals(owner, name, desc)) {
++state;
}
break;
case 3:
if (Names.tessellator_addTranslation.equals(owner, name, desc)) {
++state;
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"popEntity",
"()V");
}
break;
}
}
@Override
public void visitCode() {
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 3);
mv.visitVarInsn(ILOAD, 4);
mv.visitMethodInsn(
INVOKESTATIC,
"com/gtnewhorizons/angelica/client/Shaders",
"pushEntity",
"(" + Names.renderBlocks_.desc + Names.block_.desc + "III)V");
// ALog.info(" pushEntity");
++nPatch;
}
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.IRETURN) {
mv.visitMethodInsn(INVOKESTATIC, "com/gtnewhorizons/angelica/client/Shaders", "popEntity", "()V");
// ALog.info(" popEntity");
++nPatch;
}
mv.visitInsn(opcode);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
static final String[] fieldsBlockLightLevel = { null, "blockLightLevel05", "blockLightLevel06",
"blockLightLevel08" };
private static class MVrenBlkWithAO extends MethodVisitor {
MethodVisitor mv1;
MethodNode mn;
int nPatch = 0;
public MVrenBlkWithAO(final int access, final String name, final String desc, final String signature,
final String[] exceptions, MethodVisitor mv) {
super(Opcodes.ASM4);
super.mv = this.mn = new MethodNode(access, name, desc, signature, exceptions);
this.mv1 = mv;
}
@Override
public void visitEnd() {
mn.visitEnd();
mn.accept(mv1);
// ALog.info(" %d", nPatch);
}
@Override
public void visitLdcInsn(Object cst) {
int match1 = 0;
if (cst instanceof Float) {
float fcst = ((Float) cst).floatValue();
if (fcst == 0.5f) match1 = 1;
else if (fcst == 0.6f) match1 = 2;
else if (fcst == 0.8f) match1 = 3;
}
if (match1 != 0) {
int match2 = 0;
InsnList insns = mn.instructions;
AbstractInsnNode insn = insns.getLast();
if (insn != null && insn.getOpcode() == Opcodes.FLOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
match2 = match1;
}
}
}
}
}
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
insn = insn.getPrevious();
if (insn != null && insn.getOpcode() == Opcodes.ALOAD) {
match2 = match1;
}
}
}
}
if (match2 != 0) {
String fieldName = fieldsBlockLightLevel[match2];
mn.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", fieldName, "F");
// ALog.info(" %s", fieldName);
++nPatch;
return;
}
}
mn.visitLdcInsn(cst);
}
}
private static class MVrenBlkFVar extends MethodVisitor {
int nPatch = 0;
public MVrenBlkFVar(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int state = 0;
@Override
public void visitLdcInsn(Object cst) {
int match1 = 0;
if (cst instanceof Float) {
float fcst = ((Float) cst).floatValue();
if (fcst == 0.5f) match1 = 1;
else if (fcst == 0.6f) match1 = 2;
else if (fcst == 0.8f) match1 = 3;
}
if (match1 != 0 && state < 3) {
++state;
String fieldName = fieldsBlockLightLevel[match1];
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", fieldName, "F");
// ALog.info(" %s", fieldName);
++nPatch;
return;
}
mv.visitLdcInsn(cst);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
private static class MVrenBlkPistonExt extends MethodVisitor {
int nPatch = 0;
public MVrenBlkPistonExt(MethodVisitor mv) {
super(Opcodes.ASM4, mv);
}
int state = 0;
@Override
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
state = 1;
mv.visitTableSwitchInsn(min, max, dflt, labels);
}
@Override
public void visitLdcInsn(Object cst) {
int match1 = 0;
if (cst instanceof Float) {
float fcst = ((Float) cst).floatValue();
if (fcst == 0.5f) match1 = 1;
else if (fcst == 0.6f) match1 = 2;
else if (fcst == 0.8f) match1 = 3;
}
if (match1 != 0 && state == 1) {
String fieldName = fieldsBlockLightLevel[match1];
mv.visitFieldInsn(GETSTATIC, "com/gtnewhorizons/angelica/client/Shaders", fieldName, "F");
// ALog.info(" %s", fieldName);
++nPatch;
return;
}
mv.visitLdcInsn(cst);
}
@Override
public void visitEnd() {
mv.visitEnd();
// ALog.info(" %d", nPatch);
}
}
// private static class MVNTransform extends MethodVisitor
// {
// protected MethodVisitor mv;
// protected MethodNode mn;
// public MVNTransform(MethodNode mn, MethodVisitor mv) {
// super(Opcodes.ASM4);
// super.mv = this.mn = mn;
// this.mv = mv;
// }
//
// @Override
// public void visitEnd() {
// super.visitEnd();
// Iterator<AbstractInsnNode> it = mn.instructions.iterator();
// while (it.hasNext())
// {
// AbstractInsnNode node = it.next();
// System.out.println(node.toString());
// }
// // send to target
// mn.accept(mv);
// }
// }
}
@@ -24,12 +24,10 @@ public class AClassTransformer implements IClassTransformer {
names = new Names();
InitNames.init();
ctMap = new HashMap();
put(Names.block_, new ACTBlock());
put(Names.itemBlock_, new ACTItemBlock());
put(Names.modelRenderer_, new ACTModelRenderer());
put(Names.openGlHelper_, new ACTOpenGlHelper());
put(Names.tessellator_, new ACTTessellator());
put(Names.renderBlocks_, new ACTRenderBlocks());
put(Names.renderGlobal_, new ACTRenderGlobal());
put(Names.entityRenderer_, new ACTEntityRenderer());
put(Names.render_, new ACTRender());
@@ -148,7 +148,6 @@ public class Namer1_7_10 extends Namer {
renderBlocks_renderBlockByRenderType = m(renderBlocks_, "b", "(" + block_.desc + "III)Z");
renderBlocks_renderBlockFlowerPot = m(renderBlocks_, "a", "(" + blockFlowerPot_.desc + "III)Z");
renderBlocks_renderStdBlockWithAOP = m(renderBlocks_, "b", "(" + block_.desc + "IIIFFF)Z");
renderBlocks_renderPistonExtension = m(renderBlocks_, "c", "(" + block_.desc + "IIIZ)Z");
renderDragon_shouldRenderPass = m(renderDragon_, "a", "(" + entityDragon_.desc + "IF)I");
renderEnderman_shouldRenderPass = m(renderEnderman_, "a", "(" + entityEnderman_.desc + "IF)I");
renderSpider_shouldRenderPass = m(renderSpider_, "a", "(" + entitySpider_.desc + "IF)I");
@@ -157,7 +157,6 @@ public class NamerSrg extends Namer {
renderBlocks_renderBlockByRenderType = m(renderBlocks_, "func_147805_b", "(" + block_.desc + "III)Z");
renderBlocks_renderBlockFlowerPot = m(renderBlocks_, "func_147752_a", "(" + blockFlowerPot_.desc + "III)Z");
renderBlocks_renderStdBlockWithAOP = m(renderBlocks_, "func_147808_b", "(" + block_.desc + "IIIFFF)Z");
renderBlocks_renderPistonExtension = m(renderBlocks_, "func_147809_c", "(" + block_.desc + "IIIZ)Z");
renderDragon_shouldRenderPass = m(renderDragon_, "func_77032_a", "(" + entityDragon_.desc + "IF)I");
renderEnderman_shouldRenderPass = m(renderEnderman_, "func_77032_a", "(" + entityEnderman_.desc + "IF)I");
renderSpider_shouldRenderPass = m(renderSpider_, "func_77032_a", "(" + entitySpider_.desc + "IF)I");
@@ -214,7 +214,6 @@ public class Names {
static Meth renderBlocks_renderBlockByRenderType;
static Meth renderBlocks_renderBlockFlowerPot;
static Meth renderBlocks_renderStdBlockWithAOP;
static Meth renderBlocks_renderPistonExtension;
static Meth renderDragon_shouldRenderPass;
static Meth renderEnderman_shouldRenderPass;
static Meth renderSpider_shouldRenderPass;