aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/preloader/asm/transformers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/preloader/asm/transformers')
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java3
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java105
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java13
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_MetaGenerated_Tool.java116
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java6
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java352
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java213
7 files changed, 301 insertions, 507 deletions
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java
index f71615b7c1..dce1fa15d2 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java
@@ -21,7 +21,6 @@ import gregtech.api.GregTech_API;
import gregtech.api.enums.Materials;
import gregtech.api.enums.SubTag;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
-import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -149,7 +148,7 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity {
int mMode;
- public ClassTransformer_GT_BlockMachines_MetaPipeEntity(byte[] basicClass, boolean obfuscated, int aMode) {
+ public ClassTransformer_GT_BlockMachines_MetaPipeEntity(byte[] basicClass, int aMode) {
mMode = aMode;
ClassReader aTempReader = null;
ClassWriter aTempWriter = null;
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java
index 4394aa0f04..e123c6a9e0 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java
@@ -1,6 +1,28 @@
package gtPlusPlus.preloader.asm.transformers;
-import static org.objectweb.asm.Opcodes.*;
+import static org.objectweb.asm.Opcodes.AALOAD;
+import static org.objectweb.asm.Opcodes.AASTORE;
+import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static org.objectweb.asm.Opcodes.ACONST_NULL;
+import static org.objectweb.asm.Opcodes.ALOAD;
+import static org.objectweb.asm.Opcodes.ANEWARRAY;
+import static org.objectweb.asm.Opcodes.ASM5;
+import static org.objectweb.asm.Opcodes.DUP;
+import static org.objectweb.asm.Opcodes.F_FULL;
+import static org.objectweb.asm.Opcodes.GOTO;
+import static org.objectweb.asm.Opcodes.ICONST_0;
+import static org.objectweb.asm.Opcodes.ICONST_1;
+import static org.objectweb.asm.Opcodes.ICONST_2;
+import static org.objectweb.asm.Opcodes.IF_ICMPLT;
+import static org.objectweb.asm.Opcodes.ILOAD;
+import static org.objectweb.asm.Opcodes.INTEGER;
+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.NEW;
+import static org.objectweb.asm.Opcodes.PUTFIELD;
+import static org.objectweb.asm.Opcodes.RETURN;
+import static org.objectweb.asm.Opcodes.UNINITIALIZED_THIS;
import org.apache.logging.log4j.Level;
import org.objectweb.asm.ClassReader;
@@ -10,13 +32,14 @@ import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import cpw.mods.fml.relauncher.FMLRelaunchLog;
+import gtPlusPlus.preloader.asm.ClassesToTransform;
public class ClassTransformer_GT_BusPatch {
- public static final String aSuperInput = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Input";
- public static final String aSuperOutput = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Output";
- public static final String aInput = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus";
- public static final String aOutput = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus";
+ private static final String aSuperInputFormatted = ClassesToTransform.GTPP_MTE_HATCH_SUPER_INPUT_BUS.replace(".", "/");
+ private static final String aSuperOutputFormatted = ClassesToTransform.GTPP_MTE_HATCH_SUPER_OUTPUT_BUS.replace(".", "/");
+ private static final String aInputFormatted = ClassesToTransform.GT_MTE_HATCH_INPUTBUS.replace(".", "/");
+ private static final String aOutputFormatted = ClassesToTransform.GT_MTE_HATCH_OUTPUTBUS.replace(".", "/");
private final boolean isValid;
private final ClassReader reader;
@@ -74,7 +97,7 @@ public class ClassTransformer_GT_BusPatch {
//GT_MetaTileEntity_Hatch_InputBus
//Constructor
- if (aClassName.equals(aInput)){
+ if (aClassName.equals(ClassesToTransform.GT_MTE_HATCH_INPUTBUS)){
//Constructor 1
{
@@ -131,14 +154,14 @@ public class ClassTransformer_GT_BusPatch {
mv.visitLineNumber(16, l4);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aInputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l5 = new Label();
mv.visitLabel(l5);
mv.visitLineNumber(21, l5);
mv.visitInsn(RETURN);
Label l6 = new Label();
mv.visitLabel(l6);
- mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus;", null, l0, l6, 0);
+ mv.visitLocalVariable("this", "L"+aInputFormatted+";", null, l0, l6, 0);
mv.visitLocalVariable("aID", "I", null, l0, l6, 1);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l6, 2);
mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l6, 3);
@@ -168,14 +191,14 @@ public class ClassTransformer_GT_BusPatch {
mv.visitLineNumber(16, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aInputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(30, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aInputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l3, 2);
mv.visitLocalVariable("aSlots", "I", null, l0, l3, 3);
@@ -205,14 +228,14 @@ public class ClassTransformer_GT_BusPatch {
mv.visitLineNumber(16, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aInputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(34, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aInputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l3, 2);
mv.visitLocalVariable("aSlots", "I", null, l0, l3, 3);
@@ -231,7 +254,7 @@ public class ClassTransformer_GT_BusPatch {
//GT_MetaTileEntity_Hatch_OutputBus
//Constructor
- if (aClassName.equals(aOutput)){
+ if (aClassName.equals(ClassesToTransform.GT_MTE_HATCH_OUTPUTBUS)){
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null);
@@ -288,7 +311,7 @@ public class ClassTransformer_GT_BusPatch {
mv.visitInsn(RETURN);
Label l5 = new Label();
mv.visitLabel(l5);
- mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus;", null, l0, l5, 0);
+ mv.visitLocalVariable("this", "L"+aOutputFormatted+";", null, l0, l5, 0);
mv.visitLocalVariable("aID", "I", null, l0, l5, 1);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l5, 2);
mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l5, 3);
@@ -317,7 +340,7 @@ public class ClassTransformer_GT_BusPatch {
mv.visitInsn(RETURN);
Label l2 = new Label();
mv.visitLabel(l2);
- mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus;", null, l0, l2, 0);
+ mv.visitLocalVariable("this", "L"+aOutputFormatted+";", null, l0, l2, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l2, 2);
mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3);
@@ -346,7 +369,7 @@ public class ClassTransformer_GT_BusPatch {
mv.visitInsn(RETURN);
Label l2 = new Label();
mv.visitLabel(l2);
- mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus;", null, l0, l2, 0);
+ mv.visitLocalVariable("this", "L"+aOutputFormatted+";", null, l0, l2, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l2, 2);
mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3);
@@ -363,7 +386,7 @@ public class ClassTransformer_GT_BusPatch {
//GT_MetaTileEntity_SuperBus_Input
//Constructor
- if (aClassName.equals(aSuperInput)){
+ if (aClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_INPUT_BUS)){
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null);
@@ -376,20 +399,20 @@ public class ClassTransformer_GT_BusPatch {
mv.visitVarInsn(ALOAD, 2);
mv.visitVarInsn(ALOAD, 3);
mv.visitVarInsn(ILOAD, 4);
- mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false);
+ mv.visitMethodInsn(INVOKESPECIAL, ""+aInputFormatted+"", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(20, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aSuperInputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(28, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aSuperInputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aID", "I", null, l0, l3, 1);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 2);
mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l3, 3);
@@ -409,23 +432,23 @@ public class ClassTransformer_GT_BusPatch {
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 2);
- mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "getSlots", "(I)I", false);
+ mv.visitMethodInsn(INVOKESTATIC, ""+aSuperInputFormatted+"", "getSlots", "(I)I", false);
mv.visitVarInsn(ALOAD, 3);
mv.visitVarInsn(ALOAD, 4);
- mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ mv.visitMethodInsn(INVOKESPECIAL, ""+aInputFormatted+"", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(20, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aSuperInputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(28, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aSuperInputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l3, 2);
mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l3, 3);
@@ -444,25 +467,25 @@ public class ClassTransformer_GT_BusPatch {
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 2);
- mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "getSlots", "(I)I", false);
+ mv.visitMethodInsn(INVOKESTATIC, ""+aSuperInputFormatted+"", "getSlots", "(I)I", false);
mv.visitVarInsn(ALOAD, 3);
mv.visitInsn(ICONST_0);
mv.visitInsn(AALOAD);
mv.visitVarInsn(ALOAD, 4);
- mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ mv.visitMethodInsn(INVOKESPECIAL, ""+aInputFormatted+"", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(20, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aSuperInputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(32, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aSuperInputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l3, 2);
mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l3, 3);
@@ -479,7 +502,7 @@ public class ClassTransformer_GT_BusPatch {
//GT_MetaTileEntity_SuperBus_Output
//Constructor
- if (aClassName.equals(aSuperOutput)){
+ if (aClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_OUTPUT_BUS)){
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null);
@@ -492,20 +515,20 @@ public class ClassTransformer_GT_BusPatch {
mv.visitVarInsn(ALOAD, 2);
mv.visitVarInsn(ALOAD, 3);
mv.visitVarInsn(ILOAD, 4);
- mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false);
+ mv.visitMethodInsn(INVOKESPECIAL, ""+aOutputFormatted+"", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(18, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aSuperOutputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(26, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aSuperOutputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aID", "I", null, l0, l3, 1);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 2);
mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l3, 3);
@@ -525,23 +548,23 @@ public class ClassTransformer_GT_BusPatch {
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 2);
- mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "getSlots", "(I)I", false);
+ mv.visitMethodInsn(INVOKESTATIC, ""+aSuperOutputFormatted+"", "getSlots", "(I)I", false);
mv.visitVarInsn(ALOAD, 3);
mv.visitVarInsn(ALOAD, 4);
- mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ mv.visitMethodInsn(INVOKESPECIAL, ""+aOutputFormatted+"", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(18, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aSuperOutputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(26, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aSuperOutputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l3, 2);
mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l3, 3);
@@ -560,25 +583,25 @@ public class ClassTransformer_GT_BusPatch {
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 2);
- mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "getSlots", "(I)I", false);
+ mv.visitMethodInsn(INVOKESTATIC, ""+aSuperOutputFormatted+"", "getSlots", "(I)I", false);
mv.visitVarInsn(ALOAD, 3);
mv.visitInsn(ICONST_0);
mv.visitInsn(AALOAD);
mv.visitVarInsn(ALOAD, 4);
- mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ mv.visitMethodInsn(INVOKESPECIAL, ""+aOutputFormatted+"", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(18, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
- mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
+ mv.visitFieldInsn(PUTFIELD, ""+aSuperOutputFormatted+"", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;");
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(30, l2);
mv.visitInsn(RETURN);
Label l3 = new Label();
mv.visitLabel(l3);
- mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output;", null, l0, l3, 0);
+ mv.visitLocalVariable("this", "L"+aSuperOutputFormatted+";", null, l0, l3, 0);
mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1);
mv.visitLocalVariable("aTier", "I", null, l0, l3, 2);
mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l3, 3);
@@ -612,7 +635,7 @@ public class ClassTransformer_GT_BusPatch {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor methodVisitor;
- if ((mClassName.equals(aSuperInput) || mClassName.equals(aSuperOutput)) && access == ACC_PUBLIC && name.equals("<init>") && (desc.equals("(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V") || desc.equals("(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V"))) {
+ if ((mClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_INPUT_BUS) || mClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_OUTPUT_BUS)) && access == ACC_PUBLIC && name.equals("<init>") && (desc.equals("(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V") || desc.equals("(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V"))) {
FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Found Constructor, "+"'"+access+"', "+"'"+name+"', "+"'"+desc+"', "+"'"+signature+"'");
methodVisitor = null;
}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java
index da6abfe57c..e2d34c38e7 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java
@@ -152,19 +152,24 @@ public class ClassTransformer_GT_Client {
}
if (aGregtech != null) {
+ File file = aGregtech;
+ FileInputStream fis;
+ JarInputStream jis;
try {
- File file = aGregtech;
- FileInputStream fis = new FileInputStream(file);
- JarInputStream jis = new JarInputStream(fis);
+ fis = new FileInputStream(file);
+ jis = new JarInputStream(fis);
System.out.println(jis.markSupported());
JarEntry je;
while((je=jis.getNextJarEntry())!=null){
if (je.getName().contains("GT_MetaTileEntity_AssemblyLine")) {
FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Patchable class | "+je.getName());
+ jis.close();
return true;
}
}
- jis.close();
+ if (jis != null) {
+ jis.close();
+ }
return true;
} catch (IOException e1) {
}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_MetaGenerated_Tool.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_MetaGenerated_Tool.java
new file mode 100644
index 0000000000..b6cd9c8d67
--- /dev/null
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_MetaGenerated_Tool.java
@@ -0,0 +1,116 @@
+package gtPlusPlus.preloader.asm.transformers;
+
+import static org.objectweb.asm.Opcodes.ACC_FINAL;
+import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
+import static org.objectweb.asm.Opcodes.ALOAD;
+import static org.objectweb.asm.Opcodes.ASM5;
+import static org.objectweb.asm.Opcodes.INVOKESTATIC;
+import static org.objectweb.asm.Opcodes.RETURN;
+
+import org.apache.logging.log4j.Level;
+import org.objectweb.asm.AnnotationVisitor;
+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 gtPlusPlus.preloader.Preloader_Logger;
+
+public class ClassTransformer_GT_MetaGenerated_Tool {
+
+ private final boolean isValid;
+ private final ClassReader reader;
+ private final ClassWriter writer;
+
+ public ClassTransformer_GT_MetaGenerated_Tool(byte[] basicClass) {
+ ClassReader aTempReader = null;
+ ClassWriter aTempWriter = null;
+ aTempReader = new ClassReader(basicClass);
+ aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES);
+ aTempReader.accept(new LocalClassVisitor(aTempWriter), 0);
+ boolean completed = injectMethod("getSubItems", aTempWriter);
+ if (aTempReader != null && aTempWriter != null && completed) {
+ isValid = true;
+ } else {
+ isValid = false;
+ }
+ Preloader_Logger.LOG("GT Tool Fix", Level.INFO, "Valid? " + isValid + ".");
+ reader = aTempReader;
+ writer = aTempWriter;
+ }
+
+ public boolean isValidTransformer() {
+ return isValid;
+ }
+
+ public ClassReader getReader() {
+ return reader;
+ }
+
+ public ClassWriter getWriter() {
+ return writer;
+ }
+
+ public boolean injectMethod(String aMethodName, ClassWriter cw) {
+ MethodVisitor mv;
+ boolean didInject = false;
+ Preloader_Logger.LOG("GT Tool Fix", Level.INFO, "Injecting " + aMethodName + ".");
+ if (aMethodName.equals("getSubItems")) {
+ {
+ mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "getSubItems", "(Lnet/minecraft/item/Item;Lnet/minecraft/creativetab/CreativeTabs;Ljava/util/List;)V", null, null);
+ {
+ AnnotationVisitor av0 = mv.visitAnnotation("Lcpw/mods/fml/relauncher/SideOnly;", true);
+ av0.visitEnum("value", "Lcpw/mods/fml/relauncher/Side;", "CLIENT");
+ av0.visitEnd();
+ }
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(321, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitVarInsn(ALOAD, 2);
+ mv.visitVarInsn(ALOAD, 3);
+ mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/helpers/MethodHelper_GT", "getSubItems", "(Lgregtech/api/items/GT_MetaGenerated_Tool;Lnet/minecraft/item/Item;Lnet/minecraft/creativetab/CreativeTabs;Ljava/util/List;)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(322, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "Lgregtech/api/items/GT_MetaGenerated_Tool;", null, l0, l2, 0);
+ mv.visitLocalVariable("var1", "Lnet/minecraft/item/Item;", null, l0, l2, 1);
+ mv.visitLocalVariable("aCreativeTab", "Lnet/minecraft/creativetab/CreativeTabs;", null, l0, l2, 2);
+ mv.visitLocalVariable("aList", "Ljava/util/List;", null, l0, l2, 3);
+ mv.visitMaxs(4, 4);
+ mv.visitEnd();
+ didInject = true;
+ }
+
+ }
+ Preloader_Logger.LOG("GT Tool Fix", Level.INFO, "Method injection complete.");
+ return didInject;
+ }
+
+ public final class LocalClassVisitor extends ClassVisitor {
+
+ public LocalClassVisitor(ClassVisitor cv) {
+ super(ASM5, cv);
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ MethodVisitor methodVisitor;
+ if (name.equals("getSubItems") && desc.equals("(Lnet/minecraft/item/Item;Lnet/minecraft/creativetab/CreativeTabs;Ljava/util/List;)V")) {
+ methodVisitor = null;
+ Preloader_Logger.LOG("GT Tool Fix", Level.INFO, "Found method "+name+", removing.");
+ }
+ else {
+ methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
+ }
+ return methodVisitor;
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java
index 36c09688bc..307900ad9e 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java
@@ -15,6 +15,7 @@ import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import cpw.mods.fml.relauncher.FMLRelaunchLog;
+import gtPlusPlus.core.util.Utils;
public class ClassTransformer_GT_Utility {
@@ -66,7 +67,8 @@ public class ClassTransformer_GT_Utility {
MethodVisitor mv;
boolean didInject = false;
ClassWriter cw = getWriter();
- FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ".");
+ String aClassNameFormatted = Utils.class.getName().replace(".", "/");
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassNameFormatted+".");
if (aMethodName.equals("getTier")) {
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getTier", "(J)B", null, null);
mv.visitCode();
@@ -74,7 +76,7 @@ public class ClassTransformer_GT_Utility {
mv.visitLabel(l0);
mv.visitLineNumber(23, l0);
mv.visitVarInsn(LLOAD, 0);
- mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/Utils", "getTier", "(J)B", false);
+ mv.visitMethodInsn(INVOKESTATIC, aClassNameFormatted, "getTier", "(J)B", false);
mv.visitInsn(IRETURN);
Label l1 = new Label();
mv.visitLabel(l1);
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java
index 507e2cf974..443337bd35 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java
@@ -1,40 +1,5 @@
package gtPlusPlus.preloader.asm.transformers;
-import static org.objectweb.asm.Opcodes.*;
-
-import java.lang.reflect.Field;
-import java.util.*;
-
-import org.apache.logging.log4j.Level;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-
-import cpw.mods.fml.relauncher.FMLRelaunchLog;
-
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockContainer;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.World;
-
-import gregtech.api.GregTech_API;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.BaseMetaTileEntity;
-import gregtech.api.metatileentity.MetaTileEntity;
-import gregtech.common.blocks.GT_Block_Machines;
-
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.api.objects.minecraft.BlockPos;
-import gtPlusPlus.api.objects.random.XSTR;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
-import gtPlusPlus.core.util.minecraft.NBTUtils;
-import gtPlusPlus.core.util.reflect.ReflectionUtils;
-
public class Preloader_ClassTransformer2 {
/**
@@ -48,321 +13,4 @@ public class Preloader_ClassTransformer2 {
*
*/
-
-
- public static boolean mHasSetField = false;
-
- private final static Class<BaseMetaTileEntity> customTransformer2 = BaseMetaTileEntity.class;
- public static final class GT_MetaTile_Visitor extends ClassVisitor {
- private boolean isGt_Block_Machines = false;
-
- public GT_MetaTile_Visitor(ClassVisitor cv, boolean isGt_Block_Machines) {
- super(ASM5, cv);
- this.isGt_Block_Machines = isGt_Block_Machines;
- }
-
- @Override
- public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
- FieldVisitor j = super.visitField(access, name, desc, signature, value);
- if (!mHasSetField && !isGt_Block_Machines) {
- mHasSetField = true;
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Injecting field 'mItemStorageNBT' into BaseMetaTileEntity.java. Access OpCode: "+access);
- j = cv.visitField(0, "mItemStorageNBT", "Lnet/minecraft/nbt/NBTTagCompound;", null, null);
- j.visitEnd();
- }
- return j;
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
- MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
-
- if (isGt_Block_Machines) { //Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V
- if(name.equals("breakBlock") && desc.equals("(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V")) {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Found target method 'breakBlock' [Unobfuscated]. Access OpCode: "+access);
- return new swapBreakBlock(methodVisitor);
- }
- else if (name.equals("breakBlock") && !desc.equals("(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V")) {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Found target method 'breakBlock' [Obfuscated]. Access OpCode: "+access);
- return new swapBreakBlock(methodVisitor);
- }
- }
- else {
- if(name.equals("getDrops") && desc.equals("()Ljava/util/ArrayList;")) {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Found target method 'getDrops'. Access OpCode: "+access);
- return new swapGetDrops(methodVisitor);
- }
- }
- return methodVisitor;
- }
-
- }
-
-
-
-
- private static final class swapGetDrops extends MethodVisitor {
-
- public swapGetDrops(MethodVisitor mv) {
- super(ASM5, mv);
- }
-
- @Override
- public void visitCode() {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Fixing Greg & Blood's poor attempt at setItemNBT().");
- super.visitCode();
- //ALOAD 0
- //INVOKESTATIC gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2 getDrops (Lgregtech/api/metatileentity/BaseMetaTileEntity;)Ljava/util/ArrayList;
- //ARETURN
-
- super.visitVarInsn(ALOAD, 0);
- super.visitMethodInsn(INVOKESTATIC,
- "gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2",
- "getDrops",
- "(Lgregtech/api/metatileentity/BaseMetaTileEntity;)Ljava/util/ArrayList;",
- false);
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Method should now be replaced.");
- //super.visitVarInsn(ARETURN, 0);
- super.visitInsn(ARETURN);
- }
-
- }
-
- private static final class swapBreakBlock extends MethodVisitor {
-
- public swapBreakBlock(MethodVisitor mv) {
- super(ASM5, mv);
- }
-
- @Override
- public void visitCode() {
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Fixing breakBlock() in GT_Block_Machines.class");
- super.visitCode();
- //super.visitVarInsn(ALOAD, 0);
-
- super.visitVarInsn(ALOAD, 1);
- super.visitVarInsn(ILOAD, 2);
- super.visitVarInsn(ILOAD, 3);
- super.visitVarInsn(ILOAD, 4);
- super.visitVarInsn(ALOAD, 5);
- super.visitVarInsn(ILOAD, 6);
-
- super.visitMethodInsn(INVOKESTATIC,
- "gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2",
- "breakBlock",
- "(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;I)V",
- false);
- FMLRelaunchLog.log("[GT++ ASM] NBTFixer", Level.INFO, "Method should now be replaced.");
- super.visitInsn(RETURN);
- }
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static ArrayList<ItemStack> getDrops(BaseMetaTileEntity o) {
- Logger.INFO("BaseMetaTileEntity.getDrops(BaseMetaTileEntity(this))");
- try {
- short tID = (short) ReflectionUtils.getField(customTransformer2, "mID").get(o);
- ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, tID);
-
- NBTTagCompound i = new NBTTagCompound();
-
- i = stupidFuckingNBTMap.get(new BlockPos(o.xCoord, o.yCoord, o.zCoord, o.getWorld()));
- Logger.INFO("Got NBT Tag Value from map.");
-
- NBTTagCompound tNBT = i;
- if (tNBT == null) {
- Logger.INFO("Map tag was null.");
- tNBT = generateGetDropsNBT(o);
- }
- if (!tNBT.hasNoTags()) {
- rStack.setTagCompound(tNBT);
- Logger.INFO("Iterating rStack NBT.");
- NBTUtils.tryIterateNBTData(rStack);
- }
- return new ArrayList<ItemStack>(Arrays.asList(rStack));
- }
- catch (IllegalArgumentException | IllegalAccessException a){
- Logger.REFLECTION("getDropsHack2");
- a.printStackTrace();
- }
- ArrayList<ItemStack> u = new ArrayList<ItemStack>(Arrays.asList(new ItemStack[]{ItemUtils.getSimpleStack(Blocks.bedrock)}));
- return u;
- }
-
- public static Map<BlockPos, NBTTagCompound> stupidFuckingNBTMap = new HashMap<BlockPos, NBTTagCompound>();
- public static void breakBlock(final World aWorld, final int aX, final int aY, final int aZ, final Block block,
- final int meta) {
- Logger.INFO("GT_Block_Machines.breakBlock()");
- GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
- final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY,