From 26e797a58895400688b8fff224793cd70520183d Mon Sep 17 00:00:00 2001 From: TimeConqueror Date: Mon, 2 Aug 2021 20:49:49 +0300 Subject: Removed ASM-based SuperBuses --- src/Java/gtPlusPlus/api/objects/Logger.java | 8 +- .../preloader/asm/ClassesToTransform.java | 4 - .../transformers/ClassTransformer_GT_BusPatch.java | 653 --------------------- .../Preloader_Transformer_Handler.java | 38 +- .../GT_MetaTileEntity_SuperBus_Input.java | 17 +- .../GT_MetaTileEntity_SuperBus_Output.java | 22 +- .../gregtech/GregtechCustomHatches.java | 137 ++--- 7 files changed, 84 insertions(+), 795 deletions(-) delete mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java (limited to 'src') diff --git a/src/Java/gtPlusPlus/api/objects/Logger.java b/src/Java/gtPlusPlus/api/objects/Logger.java index 78cc19b130..894e3b2fa9 100644 --- a/src/Java/gtPlusPlus/api/objects/Logger.java +++ b/src/Java/gtPlusPlus/api/objects/Logger.java @@ -1,12 +1,10 @@ package gtPlusPlus.api.objects; -import org.apache.logging.log4j.LogManager; - import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.preloader.CORE_Preloader; -import gtPlusPlus.preloader.asm.AsmConfig; +import org.apache.logging.log4j.LogManager; public class Logger { @@ -23,9 +21,9 @@ public class Logger { return gtPlusPlusLogger; } - private static final boolean enabled = !AsmConfig.disableAllLogging; + private static final boolean enabled = true; - public static final org.apache.logging.log4j.Logger getLogger(){ + public static final org.apache.logging.log4j.Logger getLogger() { return modLogger; } diff --git a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java index ac8fd26415..1dcbff439f 100644 --- a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java +++ b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java @@ -40,15 +40,11 @@ public class ClassesToTransform { public static final String GT_METAGENERATED_TOOL = "gregtech.api.items.GT_MetaGenerated_Tool"; public static final String GT_BLOCK_MACHINES = "gregtech.common.blocks.GT_Block_Machines"; public static final String GT_MTE_HATCH_ENERGY = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy"; - public static final String GT_MTE_HATCH_INPUTBUS = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus"; - public static final String GT_MTE_HATCH_OUTPUTBUS = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus"; public static final String GT_METAPIPE_ITEM = "gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Item"; public static final String GT_METAPIPE_FLUID = "gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid"; public static final String GT_METAPIPE_FRAME = "gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame"; - public static final String GTPP_MTE_HATCH_SUPER_INPUT_BUS = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Input"; - public static final String GTPP_MTE_HATCH_SUPER_OUTPUT_BUS = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Output"; public static final String GTPP_MTE_HATCH_RTG = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG"; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java deleted file mode 100644 index e123c6a9e0..0000000000 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java +++ /dev/null @@ -1,653 +0,0 @@ -package gtPlusPlus.preloader.asm.transformers; - -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; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.ClassWriter; -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 { - - 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; - private final ClassWriter writer; - - - public ClassTransformer_GT_BusPatch(byte[] basicClass, String aClassName) { - ClassReader aTempReader = null; - ClassWriter aTempWriter = null; - - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Attempting to make GT Busses bigger."); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Patching "+aClassName+"."); - - aTempReader = new ClassReader(basicClass); - aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); - aTempReader.accept(new localClassVisitor(aTempWriter, aClassName), 0); - - if (aTempReader != null && aTempWriter != null) { - isValid = true; - } - else { - isValid = false; - } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Valid patch? "+isValid+"."); - reader = aTempReader; - writer = aTempWriter; - - - if (reader != null && writer != null) { - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Attempting Method Injection."); - injectMethod(aClassName); - } - - } - - public boolean isValidTransformer() { - return isValid; - } - - public ClassReader getReader() { - return reader; - } - - public ClassWriter getWriter() { - return writer; - } - - - public boolean injectMethod(String aClassName) { - - boolean didInject = false; - MethodVisitor mv; - ClassWriter cw = getWriter(); - int aConID = 1; - - //GT_MetaTileEntity_Hatch_InputBus - //Constructor - if (aClassName.equals(ClassesToTransform.GT_MTE_HATCH_INPUTBUS)){ - - //Constructor 1 - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(19, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_0); - mv.visitLdcInsn("Item Input for Multiblocks"); - mv.visitInsn(AASTORE); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_1); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(20, l1); - mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); - mv.visitInsn(DUP); - mv.visitLdcInsn("Capacity: "); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "(Ljava/lang/String;)V", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); - mv.visitLdcInsn(" stack"); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - Label l2 = new Label(); - mv.visitJumpInsn(IF_ICMPLT, l2); - mv.visitLdcInsn("s"); - Label l3 = new Label(); - mv.visitJumpInsn(GOTO, l3); - mv.visitLabel(l2); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 10, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder"}); - mv.visitLdcInsn(""); - mv.visitLabel(l3); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 11, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder", "java/lang/String"}); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); - mv.visitInsn(AASTORE); - mv.visitInsn(ICONST_0); - mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture"); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false); - Label l4 = new Label(); - mv.visitLabel(l4); - mv.visitLineNumber(16, l4); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ACONST_NULL); - 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", "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); - mv.visitLocalVariable("aTier", "I", null, l0, l6, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l6, 5); - mv.visitMaxs(12, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - - //Constructor 2 - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(29, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 3); - mv.visitVarInsn(ALOAD, 4); - mv.visitVarInsn(ALOAD, 5); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(16, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ACONST_NULL); - 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", "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); - mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l3, 4); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 5); - mv.visitMaxs(6, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - - //Third constructor with String[] for GT 5.09 - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(33, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 3); - mv.visitVarInsn(ALOAD, 4); - mv.visitVarInsn(ALOAD, 5); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(16, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ACONST_NULL); - 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", "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); - mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l3, 4); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 5); - mv.visitMaxs(6, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - - - - didInject = true; - } - - - //GT_MetaTileEntity_Hatch_OutputBus - //Constructor - if (aClassName.equals(ClassesToTransform.GT_MTE_HATCH_OUTPUTBUS)){ - - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(16, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_0); - mv.visitLdcInsn("Item Output for Multiblocks"); - mv.visitInsn(AASTORE); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_1); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(17, l1); - mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); - mv.visitInsn(DUP); - mv.visitLdcInsn("Capacity: "); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "(Ljava/lang/String;)V", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); - mv.visitLdcInsn(" stack"); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - Label l2 = new Label(); - mv.visitJumpInsn(IF_ICMPLT, l2); - mv.visitLdcInsn("s"); - Label l3 = new Label(); - mv.visitJumpInsn(GOTO, l3); - mv.visitLabel(l2); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 10, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder"}); - mv.visitLdcInsn(""); - mv.visitLabel(l3); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 11, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder", "java/lang/String"}); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); - mv.visitInsn(AASTORE); - mv.visitInsn(ICONST_0); - mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture"); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false); - Label l4 = new Label(); - mv.visitLabel(l4); - mv.visitLineNumber(18, l4); - mv.visitInsn(RETURN); - Label l5 = new Label(); - mv.visitLabel(l5); - 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); - mv.visitLocalVariable("aTier", "I", null, l0, l5, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l5, 5); - mv.visitMaxs(12, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(26, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 3); - mv.visitVarInsn(ALOAD, 4); - mv.visitVarInsn(ALOAD, 5); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(27, l1); - mv.visitInsn(RETURN); - Label l2 = new Label(); - mv.visitLabel(l2); - 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); - mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l2, 4); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); - mv.visitMaxs(6, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(30, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 3); - mv.visitVarInsn(ALOAD, 4); - mv.visitVarInsn(ALOAD, 5); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(31, l1); - mv.visitInsn(RETURN); - Label l2 = new Label(); - mv.visitLabel(l2); - 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); - mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l2, 4); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); - mv.visitMaxs(6, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - - didInject = true; - } - - - //GT_MetaTileEntity_SuperBus_Input - //Constructor - if (aClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_INPUT_BUS)){ - - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(27, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitMethodInsn(INVOKESPECIAL, ""+aInputFormatted+"", "", "(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, ""+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", "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); - mv.visitLocalVariable("aTier", "I", null, l0, l3, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l3, 5); - mv.visitMaxs(5, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(27, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 2); - mv.visitMethodInsn(INVOKESTATIC, ""+aSuperInputFormatted+"", "getSlots", "(I)I", false); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ALOAD, 4); - mv.visitMethodInsn(INVOKESPECIAL, ""+aInputFormatted+"", "", "(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, ""+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", "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); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); - mv.visitMaxs(6, 5); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(31, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 2); - 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, ""+aInputFormatted+"", "", "(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, ""+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", "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); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); - mv.visitMaxs(6, 5); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - - - didInject = true; - } - - - //GT_MetaTileEntity_SuperBus_Output - //Constructor - if (aClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_OUTPUT_BUS)){ - - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(25, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitMethodInsn(INVOKESPECIAL, ""+aOutputFormatted+"", "", "(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, ""+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", "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); - mv.visitLocalVariable("aTier", "I", null, l0, l3, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l3, 5); - mv.visitMaxs(5, 6); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(25, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 2); - mv.visitMethodInsn(INVOKESTATIC, ""+aSuperOutputFormatted+"", "getSlots", "(I)I", false); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ALOAD, 4); - mv.visitMethodInsn(INVOKESPECIAL, ""+aOutputFormatted+"", "", "(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, ""+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", "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); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); - mv.visitMaxs(6, 5); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - { - mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(29, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ILOAD, 2); - mv.visitVarInsn(ILOAD, 2); - 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, ""+aOutputFormatted+"", "", "(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, ""+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", "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); - mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); - mv.visitMaxs(6, 5); - mv.visitEnd(); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); - } - - didInject = true; - } - - - - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Method injection complete. Successful? "+didInject); - return didInject; - - - - } - - public final class localClassVisitor extends ClassVisitor { - - private final String mClassName; - - public localClassVisitor(ClassVisitor cv, String aClassName) { - super(ASM5, cv); - mClassName = aClassName; - } - - @Override - public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - MethodVisitor methodVisitor; - if ((mClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_INPUT_BUS) || mClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_SUPER_OUTPUT_BUS)) && access == ACC_PUBLIC && name.equals("") && (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; - } - else { - methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); - } - if (methodVisitor == null) { - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Removed Constructor with descriptor '"+desc+"' from "+mClassName); - } - return methodVisitor; - } - } - - -} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index 76355b5fde..698edf0b56 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -1,13 +1,5 @@ package gtPlusPlus.preloader.asm.transformers; -import static gtPlusPlus.preloader.asm.ClassesToTransform.*; - -import java.io.File; -import java.io.IOException; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; - import cpw.mods.fml.relauncher.CoreModManager; import cpw.mods.fml.relauncher.ReflectionHelper; import gtPlusPlus.api.objects.data.AutoMap; @@ -18,6 +10,13 @@ import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.preloader.asm.transformers.Preloader_ClassTransformer.OreDictionaryVisitor; import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.Launch; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; + +import java.io.File; +import java.io.IOException; + +import static gtPlusPlus.preloader.asm.ClassesToTransform.*; public class Preloader_Transformer_Handler implements IClassTransformer { @@ -172,10 +171,6 @@ public class Preloader_Transformer_Handler implements IClassTransformer { } - - - - /** * Gregtech ASM Patches */ @@ -184,26 +179,21 @@ public class Preloader_Transformer_Handler implements IClassTransformer { // Preloader_Logger.INFO("Gregtech Utilities Patch", "Transforming "+transformedName); // return new ClassTransformer_GT_Utility(basicClass, transformedName).getWriter().toByteArray(); // } - //Inject Custom constructors for Busses - if (transformedName.equals(GT_MTE_HATCH_INPUTBUS) || transformedName.equals(GT_MTE_HATCH_OUTPUTBUS) || transformedName.equals(GTPP_MTE_HATCH_SUPER_INPUT_BUS) || transformedName.equals(GTPP_MTE_HATCH_SUPER_OUTPUT_BUS)) { - Preloader_Logger.INFO("Gregtech Bus Patch", "Transforming "+transformedName); - return new ClassTransformer_GT_BusPatch(basicClass, transformedName).getWriter().toByteArray(); - } - //Inject Custom constructors for RTG Hatches - if (transformedName.equals(GT_MTE_HATCH_ENERGY) || transformedName.equals(GTPP_MTE_HATCH_RTG)) { - Preloader_Logger.INFO("Gregtech RTG Patch", "Transforming "+transformedName); + //Inject Custom constructors for RTG Hatches + if (transformedName.equals(GT_MTE_HATCH_ENERGY) || transformedName.equals(GTPP_MTE_HATCH_RTG)) { + Preloader_Logger.INFO("Gregtech RTG Patch", "Transforming " + transformedName); return new ClassTransformer_GT_EnergyHatchPatch(basicClass, transformedName).getWriter().toByteArray(); } //Try patch achievements - if (transformedName.equals(GT_ACHIEVEMENTS)) { - Preloader_Logger.INFO("Gregtech Achievements Patch", "Transforming "+transformedName); + if (transformedName.equals(GT_ACHIEVEMENTS)) { + Preloader_Logger.INFO("Gregtech Achievements Patch", "Transforming " + transformedName); return new ClassTransformer_GT_Achievements_CrashFix(basicClass, obfuscated).getWriter().toByteArray(); } //Fix bad handling of a loop left from original decompilation //Also Fix Achievements, although currently disabled. - if (transformedName.equals(GT_CLIENT_PROXY)) { - Preloader_Logger.INFO("Gregtech Client Proxy Patch", "Transforming "+transformedName); + if (transformedName.equals(GT_CLIENT_PROXY)) { + Preloader_Logger.INFO("Gregtech Client Proxy Patch", "Transforming " + transformedName); return new ClassTransformer_GT_Client(basicClass, obfuscated).getByteArray(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java index 4c60d9a932..c60d8ec412 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java @@ -7,6 +7,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gregtech.api.util.extensions.Arrays; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; @@ -16,26 +17,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_InputBus { - public GT_MetaTileEntity_SuperBus_Input(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier); - } - - public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); + super(aID, aName, aNameRegional, aTier, getSlots(aTier)); } public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription[0], aTextures); + super(aName, aTier, getSlots(aTier), aDescription, aTextures); } /** * Returns a factor of 16 based on tier. + * * @param aTier The tier of this bus. - * @return (1+ aTier) * 16 + * @return (1 + aTier) * 16 */ public static int getSlots(int aTier) { - return (1+ aTier) * 16; + return (1 + aTier) * 16; } public ITexture[] getTexturesActive(ITexture aBaseTexture) { @@ -63,7 +60,7 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, this.mDescription, this.mTextures); + return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, Arrays.of(this.mDescription), this.mTextures); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java index cca5a39de3..5143c97553 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java @@ -5,9 +5,9 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.util.GT_Utility; +import gregtech.api.util.extensions.Arrays; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -15,27 +15,23 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_OutputBus { - public GT_Recipe_Map mRecipeMap = null; - public GT_MetaTileEntity_SuperBus_Output(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier); + public GT_MetaTileEntity_SuperBus_Output(int id, String name, String nameRegional, int tier) { + super(id, name, nameRegional, tier, getSlots(tier)); } - public GT_MetaTileEntity_SuperBus_Output(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - } - - public GT_MetaTileEntity_SuperBus_Output(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription[0], aTextures); + public GT_MetaTileEntity_SuperBus_Output(String name, int tier, String[] description, ITexture[][][] textures) { + super(name, tier, getSlots(tier), description, textures); } /** * Returns a factor of 16 based on tier. + * * @param aTier The tier of this bus. - * @return (1+ aTier) * 16 + * @return (1 + aTier) * 16 */ public static int getSlots(int aTier) { - return (1+ aTier) * 16; + return (1 + aTier) * 16; } public boolean isValidSlot(int aIndex) { @@ -43,7 +39,7 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, this.mDescription, this.mTextures); + return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, Arrays.of(this.mDescription), this.mTextures); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java index c748da5d3c..64e77393bd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.FluidUtils; @@ -12,6 +9,8 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.*; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; +import java.lang.reflect.Constructor; + public class GregtechCustomHatches { public static void run() { @@ -120,128 +119,94 @@ public class GregtechCustomHatches { } private static void run3() { - - - /* * Super Input Busses */ int aStartID = 30021; - Class aGT_MetaTileEntity_SuperBus_Input = GT_MetaTileEntity_SuperBus_Input.class; - Class aGT_MetaTileEntity_SuperBus_Output = GT_MetaTileEntity_SuperBus_Output.class; - - GregtechItemList.Hatch_SuperBus_Input_ULV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.00", "Super Bus (I) (ULV)", 0)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.00", "Super Bus (I) (ULV)", 0)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_LV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.01", "Super Bus (I) (LV)", 1)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.01", "Super Bus (I) (LV)", 1)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_MV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.02", "Super Bus (I) (MV)", 2)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.02", "Super Bus (I) (MV)", 2)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_HV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.03", "Super Bus (I) (HV)", 3)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.03", "Super Bus (I) (HV)", 3)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_EV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.04", "Super Bus (I) (EV)", 4)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.04", "Super Bus (I) (EV)", 4)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_IV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.05", "Super Bus (I) (IV)", 5)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.05", "Super Bus (I) (IV)", 5)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_LuV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.06", "Super Bus (I) (LuV)", 6)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.06", "Super Bus (I) (LuV)", 6)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_ZPM - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.07", "Super Bus (I) (ZPM)", 7)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.07", "Super Bus (I) (ZPM)", 7)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_UV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.08", "Super Bus (I) (UV)", 8)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.08", "Super Bus (I) (UV)", 8)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Input_MAX - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Input, aStartID++, "hatch.superbus.input.tier.09", "Super Bus (I) (MAX)", 9)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.09", "Super Bus (I) (MAX)", 9)) + .getStackForm(1L)); /* * Super Output Busses */ GregtechItemList.Hatch_SuperBus_Output_ULV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.00", "Super Bus (O) (ULV)", 0)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.00", "Super Bus (O) (ULV)", 0)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_LV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.01", "Super Bus (O) (LV)", 1)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.01", "Super Bus (O) (LV)", 1)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_MV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.02", "Super Bus (O) (MV)", 2)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.02", "Super Bus (O) (MV)", 2)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_HV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.03", "Super Bus (O) (HV)", 3)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.03", "Super Bus (O) (HV)", 3)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_EV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.04", "Super Bus (O) (EV)", 4)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.04", "Super Bus (O) (EV)", 4)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_IV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.05", "Super Bus (O) (IV)", 5)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.05", "Super Bus (O) (IV)", 5)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_LuV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.06", "Super Bus (O) (LuV)", 6)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.06", "Super Bus (O) (LuV)", 6)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_ZPM - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.07", "Super Bus (O) (ZPM)", 7)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.07", "Super Bus (O) (ZPM)", 7)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_UV - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.08", "Super Bus (O) (UV)", 8)) - .getStackForm(1L)); + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.08", "Super Bus (O) (UV)", 8)) + .getStackForm(1L)); GregtechItemList.Hatch_SuperBus_Output_MAX - .set(((IMetaTileEntity) generateBus(aGT_MetaTileEntity_SuperBus_Output, aStartID++, "hatch.superbus.output.tier.09", "Super Bus (O) (MAX)", 9)) - .getStackForm(1L)); - + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.09", "Super Bus (O) (MAX)", 9)) + .getStackForm(1L)); } - private static Object generateBus(Class aClass, int aID, String aUnlocalName, String aLocalName, int aTier) { - Class aBusEntity = aClass; - Constructor constructor; - try { - constructor = aBusEntity.getConstructor(int.class, String.class, String.class, int.class, int.class); - if (constructor != null) { - Object aBus; - try { - aBus = constructor.newInstance( - aID, aUnlocalName, - aLocalName, - aTier, - (1+ aTier) * 32); - if (aBus == null) { - Logger.INFO("Failed to Generate "+aLocalName+"."); - } - else { - Logger.INFO("Generated "+aLocalName+"."); - return aBus; - } - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - e.printStackTrace(); - Logger.INFO("Failed to Generate "+aLocalName+"."); - } - } - } catch (NoSuchMethodException | SecurityException e1) { - e1.printStackTrace(); - Logger.INFO("Failed to Generate "+aLocalName+"."); - } - return null; + private static GT_MetaTileEntity_SuperBus_Input makeInputBus(int id, String unlocalizedName, String localizedName, int tier) { + return new GT_MetaTileEntity_SuperBus_Input(id, unlocalizedName, localizedName, tier); } + private static GT_MetaTileEntity_SuperBus_Output makeOutputBus(int id, String unlocalizedName, String localizedName, int tier) { + return new GT_MetaTileEntity_SuperBus_Output(id, unlocalizedName, localizedName, tier); + } private static void run4() { int aID = 31060; //41, "hatch.energy.tier.01", "LV Energy Hatch", 1 - Constructor aRTG = ReflectionUtils.getConstructor(GT_MetaTileEntity_Hatch_Energy_RTG.class, new Class[] {int.class, String.class, String.class, int.class, int.class}); - Object aHatch1 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[] {aID++, "hatch.energy.rtg.tier.01", "RTG Power Unit [LV]", 1, 9}); - Object aHatch2 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[] {aID++, "hatch.energy.rtg.tier.02", "RTG Power Unit [MV]", 2, 9}); - Object aHatch3 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[] {aID++, "hatch.energy.rtg.tier.03", "RTG Power Unit [HV]", 3, 9}); + Constructor aRTG = ReflectionUtils.getConstructor(GT_MetaTileEntity_Hatch_Energy_RTG.class, new Class[]{int.class, String.class, String.class, int.class, int.class}); + Object aHatch1 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[]{aID++, "hatch.energy.rtg.tier.01", "RTG Power Unit [LV]", 1, 9}); + Object aHatch2 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[]{aID++, "hatch.energy.rtg.tier.02", "RTG Power Unit [MV]", 2, 9}); + Object aHatch3 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[]{aID++, "hatch.energy.rtg.tier.03", "RTG Power Unit [HV]", 3, 9}); GregtechItemList.Hatch_RTG_LV.set(((IMetaTileEntity) aHatch1).getStackForm(1L)); GregtechItemList.Hatch_RTG_MV.set(((IMetaTileEntity) aHatch2).getStackForm(1L)); -- cgit