From 35f473d3f79d3b4f30e2cd02885a6e685d66fb45 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 3 Apr 2020 00:36:38 +0100 Subject: $ Patched the Thaumic Repairer from Thaumic Tinkerer. It now won't repair item's unless they're actually fucking repairable. --- .../ClassTransformer_TT_ThaumicRestorer.java | 455 +++++++++++++++++++++ .../Preloader_Transformer_Handler.java | 54 +-- 2 files changed, 462 insertions(+), 47 deletions(-) create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java (limited to 'src/Java/gtPlusPlus/preloader/asm/transformers') diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java new file mode 100644 index 0000000000..1dc8c3bc38 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java @@ -0,0 +1,455 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.*; + +import gtPlusPlus.preloader.Preloader_Logger; + +public class ClassTransformer_TT_ThaumicRestorer { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + // thaumic.tinkerer.common.block.tile.TileRepairer + + public ClassTransformer_TT_ThaumicRestorer(byte[] basicClass) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + boolean obfuscated = false; + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + AddAdapter aMethodStripper = new AddAdapter(aTempWriter); + aTempReader.accept(aMethodStripper, 0); + obfuscated = aMethodStripper.isObfuscated; + String aUpdateEntity = obfuscated ? "func_145845_h" : "updateEntity"; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Patching: "+aUpdateEntity+", Are we patching obfuscated methods? "+obfuscated); + injectMethod(aUpdateEntity, aTempWriter, obfuscated); + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", 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, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Injecting " + aMethodName + "."); + + String aItemStack = obfuscated ? "add" : "net/minecraft/item/ItemStack"; + String aItem = obfuscated ? "adb" : "net/minecraft/item/Item"; + String aGetItemDamage = obfuscated ? "func_150976_a" : "getItemDamage"; + String aGetItem = obfuscated ? "func_77973_b" : "getItem"; + String aSetItemDamage = obfuscated ? "func_77964_b" : "setItemDamage"; + String aIsRepairable = obfuscated ? "func_82789_a" : "isRepairable"; + + mv = cw.visitMethod(ACC_PUBLIC, aMethodName, "()V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(59, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "ticksExisted", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(DUP_X1); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "ticksExisted", "I"); + mv.visitIntInsn(BIPUSH, 10); + mv.visitInsn(IREM); + Label l1 = new Label(); + mv.visitJumpInsn(IFNE, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(60, l2); + mv.visitLdcInsn("TConstruct"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + Label l3 = new Label(); + mv.visitJumpInsn(IFEQ, l3); + mv.visitFieldInsn(GETSTATIC, "thaumic/tinkerer/common/core/handler/ConfigHandler", "repairTConTools", "Z"); + mv.visitJumpInsn(IFEQ, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(61, l4); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitJumpInsn(IFNULL, l3); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(62, l5); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "isTConstructTool", "(L"+aItemStack+";)Z", false); + mv.visitJumpInsn(IFEQ, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(63, l6); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "getDamage", "(L"+aItemStack+";)I", false); + mv.visitVarInsn(ISTORE, 1); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(64, l7); + mv.visitVarInsn(ILOAD, 1); + Label l8 = new Label(); + mv.visitJumpInsn(IFLE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(65, l9); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "drawEssentia", "()I", false); + mv.visitVarInsn(ISTORE, 2); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(66, l10); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "fixDamage", "(L"+aItemStack+";I)Z", false); + mv.visitInsn(POP); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(67, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "markDirty", "()V", false); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(68, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + Label l13 = new Label(); + mv.visitJumpInsn(IFEQ, l13); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitJumpInsn(IF_ICMPEQ, l13); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(69, l14); + mv.visitFieldInsn(GETSTATIC, "thaumic/tinkerer/common/ThaumicTinkerer", "tcProxy", "Lthaumcraft/common/CommonProxy;"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "xCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "yCoord", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2D); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "zCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/CommonProxy", "sparkle", "(FFFI)V", false); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(70, l15); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_1); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l16 = new Label(); + mv.visitLabel(l16); + mv.visitLineNumber(71, l16); + Label l17 = new Label(); + mv.visitJumpInsn(GOTO, l17); + mv.visitLabel(l13); + mv.visitFrame(Opcodes.F_APPEND,2, new Object[] {Opcodes.INTEGER, Opcodes.INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(72, l18); + mv.visitJumpInsn(GOTO, l17); + mv.visitLabel(l8); + mv.visitFrame(Opcodes.F_CHOP,1, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + mv.visitLabel(l17); + mv.visitLineNumber(73, l17); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + Label l19 = new Label(); + mv.visitJumpInsn(IFNONNULL, l19); + mv.visitInsn(ICONST_0); + Label l20 = new Label(); + mv.visitJumpInsn(GOTO, l20); + mv.visitLabel(l19); + mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer"}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "getDamage", "(L"+aItemStack+";)I", false); + mv.visitLabel(l20); + mv.visitFrame(Opcodes.F_FULL, 2, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer", Opcodes.INTEGER}, 2, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer", Opcodes.INTEGER}); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(74, l21); + mv.visitInsn(RETURN); + mv.visitLabel(l3); + mv.visitLineNumber(78, l3); + mv.visitFrame(Opcodes.F_CHOP,1, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + Label l22 = new Label(); + mv.visitJumpInsn(IFNULL, l22); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItemDamage+"", "()I", false); + mv.visitJumpInsn(IFLE, l22); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItem+"", "()L"+aItem+";", false); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItem+"", ""+aIsRepairable+"", "()Z", false); + mv.visitJumpInsn(IFEQ, l22); + Label l23 = new Label(); + mv.visitLabel(l23); + mv.visitLineNumber(79, l23); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "drawEssentia", "()I", false); + mv.visitVarInsn(ISTORE, 1); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitLineNumber(80, l24); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItemDamage+"", "()I", false); + mv.visitVarInsn(ISTORE, 2); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(81, l25); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ISUB); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aSetItemDamage+"", "(I)V", false); + Label l26 = new Label(); + mv.visitLabel(l26); + mv.visitLineNumber(82, l26); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "markDirty", "()V", false); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(84, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + Label l28 = new Label(); + mv.visitJumpInsn(IFEQ, l28); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + mv.visitVarInsn(ILOAD, 2); + mv.visitJumpInsn(IF_ICMPEQ, l28); + Label l29 = new Label(); + mv.visitLabel(l29); + mv.visitLineNumber(85, l29); + mv.visitFieldInsn(GETSTATIC, "thaumic/tinkerer/common/ThaumicTinkerer", "tcProxy", "Lthaumcraft/common/CommonProxy;"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "xCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "yCoord", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2D); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "zCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/CommonProxy", "sparkle", "(FFFI)V", false); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(86, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_1); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(87, l31); + Label l32 = new Label(); + mv.visitJumpInsn(GOTO, l32); + mv.visitLabel(l28); + mv.visitFrame(Opcodes.F_APPEND,2, new Object[] {Opcodes.INTEGER, Opcodes.INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(88, l33); + mv.visitJumpInsn(GOTO, l32); + mv.visitLabel(l22); + mv.visitFrame(Opcodes.F_CHOP,2, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + mv.visitLabel(l32); + mv.visitLineNumber(90, l32); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + Label l34 = new Label(); + mv.visitJumpInsn(IFNONNULL, l34); + mv.visitInsn(ICONST_0); + Label l35 = new Label(); + mv.visitJumpInsn(GOTO, l35); + mv.visitLabel(l34); + mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer"}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItemDamage+"", "()I", false); + mv.visitLabel(l35); + mv.visitFrame(Opcodes.F_FULL, 1, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer"}, 2, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer", Opcodes.INTEGER}); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + mv.visitLabel(l1); + mv.visitLineNumber(92, l1); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l36 = new Label(); + mv.visitLabel(l36); + mv.visitLocalVariable("this", "Lthaumic/tinkerer/common/block/tile/TileRepairer;", null, l0, l36, 0); + mv.visitLocalVariable("dmg", "I", null, l7, l3, 1); + mv.visitLocalVariable("essentia", "I", null, l10, l18, 2); + mv.visitLocalVariable("essentia", "I", null, l24, l33, 1); + mv.visitLocalVariable("dmg", "I", null, l25, l33, 2); + mv.visitMaxs(9, 3); + mv.visitEnd(); + didInject = true; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Method injection complete. "+(obfuscated ? "Obfuscated" : "Non-Obfuscated")); + return didInject; + } + + public class AddAdapter extends ClassVisitor { + + public AddAdapter(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + private final String[] aMethodsToStrip = new String[] {"updateEntity", "func_145845_h"}; + public boolean isObfuscated = false; + + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + + MethodVisitor methodVisitor; + boolean found = false; + + for (String s : aMethodsToStrip) { + if (name.equals(s)) { + found = true; + if (s.equals(aMethodsToStrip[1])) { + isObfuscated = true; + } + break; + } + } + if (!found) { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + else { + methodVisitor = null; + } + + if (found) { + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, + "Found method " + name + ", removing."); + } + 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 5dc7dcfbc8..398e69a2f9 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -1,52 +1,6 @@ package gtPlusPlus.preloader.asm.transformers; -import static gtPlusPlus.preloader.asm.ClassesToTransform.COFH_ORE_DICTIONARY_ARBITER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.FORGE_CHUNK_MANAGER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.FORGE_ORE_DICTIONARY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GALACTICRAFT_ENTITY_AUTO_ROCKET; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GALACTICRAFT_FLUID_UTILS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GALACTICRAFT_TILE_ENTITY_FUEL_LOADER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GTPP_MTE_HATCH_SUPER_INPUT_BUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GTPP_MTE_HATCH_SUPER_OUTPUT_BUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_ACHIEVEMENTS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_BASE_META_TILE_ENTITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_BLOCK_MACHINES; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_CLIENT_PROXY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_ITEM_MACHINES; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAGENERATED_TOOL; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAPIPE_FLUID; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAPIPE_FRAME; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAPIPE_ITEM; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_MTE_CHARCOAL_PIT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_MTE_HATCH_INPUTBUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_MTE_HATCH_OUTPUTBUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_PACKET_TILE_ENTITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_UTILITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_BASE_TILE_ENTITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_CHARGEPAD; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_ELECTRIC; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_GENERATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_HEAT_GENERATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_KINETIC_GENERATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_LUMINATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_MACHINE1; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_MACHINE2; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_MACHINE3; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_PERSONAL; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_ACCESS_HATCH; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_CHAMBER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_FLUID_PORT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_REDSTONE_PORT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_VESSEL; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_ITEM_ARMOUR_HAZMAT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.LWJGL_KEYBOARD; -import static gtPlusPlus.preloader.asm.ClassesToTransform.MINECRAFT_GAMESETTINGS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.MINECRAFT_GAMESETTINGS_OBF; -import static gtPlusPlus.preloader.asm.ClassesToTransform.RAILCRAFT_FLUID_HELPER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.RAILCRAFT_INVENTORY_TOOLS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.RAILCRAFT_TILE_FLUID_LOADER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.THAUMCRAFT_ITEM_WISP_ESSENCE; -import static gtPlusPlus.preloader.asm.ClassesToTransform.TINKERS_FLUID_BLOCK; +import static gtPlusPlus.preloader.asm.ClassesToTransform.*; import java.io.File; import java.io.IOException; @@ -317,6 +271,12 @@ public class Preloader_Transformer_Handler implements IClassTransformer { Preloader_Logger.INFO("Thaumcraft WispEssence_Patch", "Transforming "+transformedName); return new ClassTransformer_TC_ItemWispEssence(basicClass, obfuscated).getWriter().toByteArray(); } + //Fix Thaumic Tinkerer Shit + //Patching ItemWispEssence to allow invalid item handling + if (transformedName.equals(THAUMICTINKERER_TILE_REPAIRER)) { + Preloader_Logger.INFO("Thaumic Tinkerer RepairItem Patch", "Transforming "+transformedName); + return new ClassTransformer_TT_ThaumicRestorer(basicClass).getWriter().toByteArray(); + } return basicClass; -- cgit From cfbd10cfb2644a981b9b2763166aa66fce5cd491 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 7 Apr 2020 15:12:31 +0100 Subject: + Added support for Custom Machines being registered to the PA. (If GT is up-to date) + Added more ASM patches for better Hazmat handling. % Renamed Chemical Dehydrator to Dehydrator for clearer logic in NEI. $ Fixed a small bug in ReflectionUtils. $ Rewrote parts of my Hazmat handling, it should now work correctly for all items which apply radiation from IC2/GT or their addons. --- src/Java/gregtech/api/util/Recipe_GT.java | 13 +- src/Java/gtPlusPlus/GTplusplus.java | 2 +- .../core/util/minecraft/HazmatUtils.java | 222 ++++--- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 42 +- .../core/util/reflect/ReflectionUtils.java | 8 +- .../transformers/ClassTransformer_GT_Utility.java | 664 ++++++++++++++++++++- .../transformers/ClassTransformer_IC2_Hazmat.java | 6 +- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 4 + .../loaders/misc/AddCustomMachineToPA.java | 51 ++ 9 files changed, 880 insertions(+), 132 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java (limited to 'src/Java/gtPlusPlus/preloader/asm/transformers') diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 14e391316c..cb70d4a616 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -1,6 +1,8 @@ package gregtech.api.util; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; +import static gregtech.api.enums.GT_Values.W; import java.util.*; @@ -12,9 +14,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map_Fuel; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map_Macerator; import gtPlusPlus.api.interfaces.IComparableRecipe; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -24,7 +23,9 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.nei.GT_NEI_MultiBlockHandler; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; /** * Custom GT Recipe Class @@ -248,7 +249,7 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ public static final GT_Recipe_Map_Fuel sRocketFuels = new GT_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true); public static final GT_Recipe_Map sGeoThermalFuels = new GT_Recipe_Map(new HashSet(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map sChemicalDehydratorRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.chemicaldehydrator", "Chemical Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sChemicalDehydratorRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.chemicaldehydrator", "Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sVacuumFurnaceRecipes = new GT_Recipe_Map(new HashSet(500), "gt.recipe.vacfurnace", "Vacuum Furnace", null, "gregtech:textures/gui/basicmachines/Default", 2, 2, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); public static final GT_Recipe_Map sAlloyBlastSmelterRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 9, 9, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sSteamTurbineFuels = new GT_Recipe_Map(new HashSet(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 0e70baf524..4ddec1f9f4 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -182,7 +182,6 @@ public class GTplusplus implements ActionListener { public void init(final FMLInitializationEvent event) { INIT_PHASE.INIT.setPhaseActive(true); proxy.init(event); - HazmatUtils.init(); proxy.registerNetworkStuff(); Meta_GT_Proxy.init(); Core_Manager.init(); @@ -199,6 +198,7 @@ public class GTplusplus implements ActionListener { public void postInit(final FMLPostInitializationEvent event) { INIT_PHASE.POST_INIT.setPhaseActive(true); proxy.postInit(event); + HazmatUtils.init(); BookHandler.runLater(); Meta_GT_Proxy.postInit(); Core_Manager.postInit(); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index 87c9517c9d..1bb4c53bd2 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -1,31 +1,28 @@ package gtPlusPlus.core.util.minecraft; -import static gregtech.api.GregTech_API.sBioHazmatList; -import static gregtech.api.GregTech_API.sElectroHazmatList; -import static gregtech.api.GregTech_API.sFrostHazmatList; -import static gregtech.api.GregTech_API.sGasHazmatList; -import static gregtech.api.GregTech_API.sHeatHazmatList; -import static gregtech.api.GregTech_API.sRadioHazmatList; - -import java.util.Collections; +import static gregtech.api.GregTech_API.*; + +import java.lang.reflect.Field; import java.util.HashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.GregTech_API; import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import ic2.core.Ic2Items; import ic2.core.item.armor.ItemArmorHazmat; import ic2.core.item.armor.ItemArmorNanoSuit; import ic2.core.item.armor.ItemArmorQuantumSuit; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -33,44 +30,15 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class HazmatUtils { public static final GT_HashSet sHazmatList = new GT_HashSet(); + + private static final HashMap aIgnoreNBTMap = new HashMap(); private static final HashMap> mToolTips = new HashMap>(); private static boolean mInit = false; private static HazmatUtils mInstance; - - private static final String[] mDefaultHazmat = new String[] { - "IC2:itemArmorNanoHelmet:27", - "IC2:itemArmorNanoChestplate:27", - "IC2:itemArmorNanoLegs:27", - "IC2:itemArmorNanoBoots:27", - - "IC2:itemArmorQuantumHelmet:27", - "IC2:itemArmorQuantumChestplate:27", - "IC2:itemArmorQuantumLegs:27", - "IC2:itemArmorQuantumBoots:27", - }; - - - private static final String[] mGravisuit = new String[] { - "GraviSuite:advNanoChestPlate:27", - "GraviSuite:graviChestPlate:27", - }; - private static final String[] mElectroMagicTools = new String[] { - "EMT:NanosuitGogglesRevealing:27", - "EMT:NanoBootsTraveller:27", - "EMT:NanosuitWing:27", - "EMT:itemArmorQuantumChestplate:27", - "EMT:QuantumGogglesRevealing:27", - "EMT:QuantumBootsTraveller:27", - "EMT:QuantumWing:27", - }; - private static final String[] mAdvancedSolarPanels = new String[] { - "AdvancedSolarPanel:advanced_solar_helmet:27", - "AdvancedSolarPanel:hybrid_solar_helmet:27", - "AdvancedSolarPanel:ultimate_solar_helmet:27", - }; + @SuppressWarnings("rawtypes") public static void init() { if (mInit) { return; @@ -78,40 +46,101 @@ public class HazmatUtils { mInstance = new HazmatUtils(); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatHelmet, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatChestplate, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatLeggings, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatBoots, 1)); // Make Nano a hazmat suit // Make Quantum a hazmat suit if (LoadedMods.IndustrialCraft2 || LoadedMods.IndustrialCraft2Classic) { - for (String aItemName : mDefaultHazmat) { - String[] aSplit = aItemName.split(":"); - addProtection(GT_ModHandler.getIC2Item(aSplit[1], 1L, 32767)); + AutoMap aVanillaIC2Armour = new AutoMap(); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoHelmet, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBodyarmor, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoLeggings, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBoots, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumHelmet, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBodyarmor, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumLeggings, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBoots, 1)); + for (ItemStack aItem : aVanillaIC2Armour) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered IC2 Items as hazmat gear."); } if (LoadedMods.isModLoaded("EMT")) { - for (String aItemName : mElectroMagicTools) { - addProtection(ItemUtils.getItemStackFromFQRN(aItemName, 1)); + AutoMap aItemFields = new AutoMap(); + Class aItemsEMT = ReflectionUtils.getClass("emt.init.EMTItems"); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoThaumicHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoWing")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoBootsTraveller")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumThaumicHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumWing")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumArmor")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumBootsTraveller")); + AutoMap aEMT = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = null; + if (aItemField != null) { + try { + aItemObject = (Item) aItemField.get(null); + } + catch (Exception t) { + t.printStackTrace(); + } + } + if (aItemObject != null) { + aEMT.add(ItemUtils.getSimpleStack(aItemObject)); + } + else { + Logger.INFO("[Hazmat] Could not get "+aItemField.getName()+" from "+aItemsEMT.getName()); + } + } + Logger.INFO("[Hazmat] Registering "+aEMT.size()+" EMT Items as hazmat gear."); + for (ItemStack aItem : aEMT) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered EMT Items as hazmat gear."); } - if (LoadedMods.isModLoaded("GraviSuite")) { - for (String aItemName : mGravisuit) { - addProtection(ItemUtils.getItemStackFromFQRN(aItemName, 1)); + if (LoadedMods.isModLoaded("GraviSuite")) { + AutoMap aItemFields = new AutoMap(); + Class aItemsGravisuite = ReflectionUtils.getClass("gravisuite.GraviSuite"); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "advNanoChestPlate")); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "graviChestPlate")); + AutoMap aGravisuite = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = (Item) ReflectionUtils.getFieldValue(aItemField); + if (aItemObject != null) { + aGravisuite.add(ItemUtils.getSimpleStack(aItemObject)); + } + } + Logger.INFO("[Hazmat] Registering "+aGravisuite.size()+" Gravisuit Items as hazmat gear."); + for (ItemStack aItem : aGravisuite) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered Gravisuit Items as hazmat gear."); } if (LoadedMods.isModLoaded("AdvancedSolarPanel")) { - for (String aItemName : mAdvancedSolarPanels) { - addProtection(ItemUtils.getItemStackFromFQRN(aItemName, 1)); + AutoMap aItemFields = new AutoMap(); + Class aItemsEMT = ReflectionUtils.getClass("advsolar.common.AdvancedSolarPanel"); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "advancedSolarHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "hybridSolarHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "ultimateSolarHelmet")); + AutoMap aASP = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = (Item) ReflectionUtils.getFieldValue(aItemField); + if (aItemObject != null) { + aASP.add(ItemUtils.getSimpleStack(aItemObject)); + } + } + Logger.INFO("[Hazmat] Registering "+aASP.size()+" Adv. Solar Items as hazmat gear."); + for (ItemStack aItem : aASP) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered Adv. Solar Items as hazmat gear."); } @@ -127,38 +156,36 @@ public class HazmatUtils { @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { //Logger.INFO("Ticking Hazmat handler"); - if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED - && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) { - //Logger.INFO("[Hazmat] Bad Phase : " + GTplusplus.CURRENT_LOAD_PHASE); - return; - } - if (event.itemStack == null || isVanillaHazmatPiece(event.itemStack)) { - //Logger.INFO("[Hazmat] Invalid Itemstack or vanilla hazmat"); - return; - } else { - ItemStack aStackTemp = event.itemStack; - GT_ItemStack aStack = new GT_ItemStack(aStackTemp); - if (isNanoArmourPiece(aStackTemp) || isQuantumArmourPiece(aStackTemp)) { - event.toolTip.add(EnumChatFormatting.DARK_PURPLE+"Provides full hazmat protection."); - } - else { - //Logger.INFO("[Hazmat] Finding Tooltip Data"); - String[] aTooltips = getTooltips(aStack); - if (aTooltips == null || aTooltips.length == 0) { - //Logger.INFO("[Hazmat] No Info!"); - return; - } else { - //Logger.INFO("[Hazmat] Found Tooltips!"); - if (providesProtection(aStackTemp)) { - event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE+"Provides full hazmat protection."); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + + if (event.itemStack == null || isVanillaHazmatPiece(event.itemStack)) { + //Logger.INFO("[Hazmat] Invalid Itemstack or vanilla hazmat"); + return; + } else { + ItemStack aStackTemp = event.itemStack; + GT_ItemStack aStack = new GT_ItemStack(aStackTemp); + if (isNanoArmourPiece(aStackTemp) || isQuantumArmourPiece(aStackTemp)) { + event.toolTip.add(EnumChatFormatting.DARK_PURPLE+"Provides full hazmat protection."); + } + else { + //Logger.INFO("[Hazmat] Finding Tooltip Data"); + String[] aTooltips = getTooltips(aStack); + if (aTooltips == null || aTooltips.length == 0) { + //Logger.INFO("[Hazmat] No Info!"); + return; } else { - event.toolTip.add(mToolTipText); - for (String r : aTooltips) { - event.toolTip.add(" - " + r); + //Logger.INFO("[Hazmat] Found Tooltips!"); + if (providesProtection(aStackTemp)) { + event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE+"Provides full hazmat protection."); + } else { + event.toolTip.add(mToolTipText); + for (String r : aTooltips) { + event.toolTip.add(" - " + r); + } } } - } - } + } + } } } @@ -176,7 +203,7 @@ public class HazmatUtils { if (living == null || living.isDead) { return false; } else { - + // Map All Player Armour slots AutoMap aEquipment = new AutoMap(); for (int i = 1; i < 5; ++i) { @@ -193,11 +220,13 @@ public class HazmatUtils { // Compare Equipment to all items mapped for full hazmat. for (ItemStack aSlotStack : aEquipment) { if (!isHazmatPiece(aSlotStack)) { + //Logger.INFO("Found item which is not hazmat. "+ItemUtils.getItemName(aSlotStack)); return false; } } // We are in some kind of full hazmat, huzzah! + //Logger.INFO("Has full hazmat."); return true; } } @@ -250,8 +279,8 @@ public class HazmatUtils { * @return - Did we register this ItemStack properly? */ public static boolean addProtection(ItemStack aVanStack) { - if (ItemUtils.checkForInvalidItems(aVanStack)) { - Logger.INFO("=========================Bad Hazmat Addition=============="); + if (!ItemUtils.checkForInvalidItems(aVanStack)) { + Logger.INFO("=================Bad Hazmat Addition======================"); Logger.INFO("Called from: "+ReflectionUtils.getMethodName(0)); Logger.INFO(ReflectionUtils.getMethodName(1)); Logger.INFO(ReflectionUtils.getMethodName(2)); @@ -276,6 +305,7 @@ public class HazmatUtils { return false; } } + aIgnoreNBTMap.put(aVanStack.getItem(), true); Logger.INFO("[Hazmat] Protection added for all 6 damage types, registering to master Hazmat list."); sHazmatList.add(aStack); return true; @@ -360,23 +390,29 @@ public class HazmatUtils { } for (GT_ItemStack o : aSet) { if (o != null) { + if (GT_Utility.areStacksEqual(o.toStack(), aStack, true)) { + return true; + } if (o.isStackEqual(aStack)){ return true; } + if (o.mItem == aStack.getItem() && EnergyUtils.EU.isElectricItem(aStack)) { + return true; + } } } return false; } private static String[] getTooltips(GT_ItemStack aStack) { - String aKey = convertGtItemstackToStringData(aStack); + String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); AutoMap aTempTooltipData = mToolTips.get(aKey); - if (aTempTooltipData == null) { + if (aTempTooltipData == null || aTempTooltipData.isEmpty()) { //Logger.INFO("[Hazmat] Item was not mapped for TTs - "+aKey); return new String[] {}; } else { //Logger.INFO("[Hazmat] Item was mapped for TTs"); - Collections.sort(aTempTooltipData); + //Collections.sort(aTempTooltipData); //Logger.INFO("[Hazmat] Sorted TTs"); String[] mBuiltOutput = new String[aTempTooltipData.size()]; @@ -390,15 +426,15 @@ public class HazmatUtils { } private static void registerTooltip(GT_ItemStack aStack, String aTooltip) { - String aKey = convertGtItemstackToStringData(aStack); + String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); Logger.INFO("[Hazmat] Mapping " + aTooltip + " for " + aKey); AutoMap aTempTooltipData = mToolTips.get(aKey); if (aTempTooltipData == null) { Logger.INFO("No data mapped yet, creating."); aTempTooltipData = new AutoMap(); + mToolTips.put(aKey, aTempTooltipData); } aTempTooltipData.add(aTooltip); - mToolTips.put(convertGtItemstackToStringData(aStack), aTempTooltipData); } public static ItemStack getStackFromGtStack(GT_ItemStack aGtStack) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 3cb2d4cec3..19a40fd9e6 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -109,7 +109,7 @@ public class ItemUtils { final ItemStack y = ItemUtils.simpleMetaStack(x, WILDCARD_VALUE, 1); return y; } - + public static ItemStack getIC2Cell(final String S) { final ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + S, 1); @@ -174,7 +174,7 @@ public class ItemUtils { Logger.ERROR(ItemUtils.getItemName(stack) + " not registered. [NULL]"); } } - + public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName) { addItemToOreDictionary(stack, oreDictName, false); } @@ -291,19 +291,29 @@ public class ItemUtils { public static ItemStack getItemStackFromFQRN(final String fqrn, final int Size) // fqrn = fully qualified resource name { + Logger.INFO("Trying to split string '"+fqrn+"'."); final String[] fqrnSplit = fqrn.split(":"); if (fqrnSplit.length < 2) { return null; } - else if (fqrnSplit.length == 2) { - return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); - } else { - if (fqrnSplit.length == 3) { + if (fqrnSplit.length == 2) { + Logger.INFO("Mod: "+fqrnSplit[0]+", Item: "+fqrnSplit[1]); + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + } + else if (fqrnSplit.length == 3 && fqrnSplit[2] != null && fqrnSplit[2].length() > 0) { + Logger.INFO("Mod: "+fqrnSplit[0]+", Item: "+fqrnSplit[1]+", Meta: "+fqrnSplit[2]); ItemStack aStack = GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); - int aMeta = Integer.getInteger(fqrnSplit[2]); - return ItemUtils.simpleMetaStack(aStack, aMeta, Size); + int aMeta = Integer.parseInt(fqrnSplit[2]); + if (aStack != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)){ + return ItemUtils.simpleMetaStack(aStack, aMeta, Size); + } + else { + Logger.INFO("Could not find instance of Item: "+fqrnSplit[1]); + + } } + } return null; } @@ -1081,11 +1091,11 @@ public class ItemUtils { } - + public static String getFluidName(FluidStack aFluid) { return aFluid != null ? aFluid.getFluid().getLocalizedName(aFluid) : "NULL"; } - + public static String getFluidName(Fluid aFluid) { return aFluid != null ? aFluid.getLocalizedName() : "NULL"; } @@ -1262,7 +1272,7 @@ public class ItemUtils { } return false; } - + public static boolean isCatalyst(ItemStack aStack) { if (GT_Utility.areStacksEqual(aStack, RocketFuels.Formaldehyde_Catalyst_Stack, true)) { return true; @@ -1293,7 +1303,7 @@ public class ItemUtils { } return false; } - + public static boolean isMillingBall(ItemStack aStack) { if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { return true; @@ -1307,9 +1317,9 @@ public class ItemUtils { public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { return LangUtils.getLocalizedNameOfBlock(aBlock, aMeta); } - - + + public static boolean doesItemListEntryExist(String string) { ItemList[] aListValues = ItemList.class.getEnumConstants(); for (ItemList aItem : aListValues) { @@ -1337,11 +1347,11 @@ public class ItemUtils { } return aOther; } - + public static ItemStack getValueOfItemList(String string, int aAmount, ItemList aOther) { return getValueOfItemList(string, aOther).get(aAmount); } - + public static ItemStack getValueOfItemList(String string, int aAmount, ItemStack aOther) { ItemList[] aListValues = ItemList.class.getEnumConstants(); for (ItemList aItem : aListValues) { diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 59d20835ae..8b9b5cf94f 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -537,17 +537,17 @@ public class ReflectionUtils { public static Object invokeNonBool(Object objectInstance, Method method, Object[] values){ - if (objectInstance == null || method == null || values == null){ + if ((!ReflectionUtils.isStaticMethod(method) && objectInstance == null) || method == null || values == null){ return false; } String methodName = method.getName(); - Class mLocalClass = (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+"."); + String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); try { return method.invoke(objectInstance, values); } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); } Logger.REFLECTION("Invoke failed or did something wrong."); 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 307900ad9e..3381518c1f 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java @@ -1,11 +1,6 @@ package gtPlusPlus.preloader.asm.transformers; -import static org.objectweb.asm.Opcodes.ACC_PUBLIC; -import static org.objectweb.asm.Opcodes.ACC_STATIC; -import static org.objectweb.asm.Opcodes.ASM5; -import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.objectweb.asm.Opcodes.IRETURN; -import static org.objectweb.asm.Opcodes.LLOAD; +import static org.objectweb.asm.Opcodes.*; import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; @@ -47,6 +42,7 @@ public class ClassTransformer_GT_Utility { if (reader != null && writer != null) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Attempting Method Injection."); injectMethod("getTier"); + injectMethod("applyRadioactivity"); } } @@ -85,6 +81,638 @@ public class ClassTransformer_GT_Utility { mv.visitEnd(); didInject = true; } + if (aMethodName.equals("applyRadioactivity")){ + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "applyRadioactivity", "(Lnet/minecraft/entity/EntityLivingBase;II)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1352, l0); + mv.visitVarInsn(ILOAD, 1); + Label l1 = new Label(); + mv.visitJumpInsn(IFLE, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitJumpInsn(IFNULL, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getCreatureAttribute", "()Lnet/minecraft/entity/EnumCreatureAttribute;", false); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/entity/EnumCreatureAttribute", "UNDEAD", "Lnet/minecraft/entity/EnumCreatureAttribute;"); + mv.visitJumpInsn(IF_ACMPEQ, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getCreatureAttribute", "()Lnet/minecraft/entity/EnumCreatureAttribute;", false); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/entity/EnumCreatureAttribute", "ARTHROPOD", "Lnet/minecraft/entity/EnumCreatureAttribute;"); + mv.visitJumpInsn(IF_ACMPEQ, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "ic2/core/item/armor/ItemArmorHazmat", "hasCompleteHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitJumpInsn(IFNE, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(1353, l2); + mv.visitInsn(ACONST_NULL); + mv.visitVarInsn(ASTORE, 3); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(1354, l3); + mv.visitVarInsn(ALOAD, 0); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "moveSlowdown", "Lnet/minecraft/potion/Potion;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitIntInsn(SIPUSH, 140); + mv.visitInsn(IMUL); + mv.visitVarInsn(ILOAD, 2); + mv.visitInsn(IMUL); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "moveSlowdown", "Lnet/minecraft/potion/Potion;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); + mv.visitInsn(DUP); + mv.visitVarInsn(ASTORE, 3); + Label l5 = new Label(); + mv.visitJumpInsn(IFNONNULL, l5); + mv.visitInsn(ICONST_0); + Label l6 = new Label(); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l5); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l4, l4, INTEGER, INTEGER, INTEGER}); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); + mv.visitLabel(l6); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l4, l4, INTEGER, INTEGER, INTEGER, INTEGER}); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitInsn(IADD); + mv.visitInsn(ICONST_0); + mv.visitInsn(ICONST_5); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(IMUL); + mv.visitIntInsn(BIPUSH, 7); + mv.visitInsn(IDIV); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(1355, l7); + mv.visitVarInsn(ALOAD, 0); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "digSlowdown", "Lnet/minecraft/potion/Potion;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitIntInsn(SIPUSH, 150); + mv.visitInsn(IMUL); + mv.visitVarInsn(ILOAD, 2); + mv.visitInsn(IMUL); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "digSlowdown", "Lnet/minecraft/potion/Potion;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); + mv.visitInsn(DUP); + mv.visitVarInsn(ASTORE, 3); + Label l9 = new Label(); + mv.visitJumpInsn(IFNONNULL, l9); + mv.visitInsn(ICONST_0); + Label l10 = new Label(); + mv.visitJumpInsn(GOTO, l10); + mv.visitLabel(l9); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l8, l8, INTEGER, INTEGER, INTEGER}); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); + mv.visitLabel(l10); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l8, l8, INTEGER, INTEGER, INTEGER, INTEGER}); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitInsn(IADD); + mv.visitInsn(ICONST_0); + mv.visitInsn(ICONST_5); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(IMUL); + mv.visitIntInsn(BIPUSH, 7); + mv.visitInsn(IDIV); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(1356, l11); + mv.visitVarInsn(ALOAD, 0); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "confusion", "Lnet/minecraft/potion/Potion;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitIntInsn(SIPUSH, 130); + mv.visitInsn(IMUL); + mv.visitVarInsn(ILOAD, 2); + mv.visitInsn(IMUL); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "confusion", "Lnet/minecraft/potion/Potion;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); + mv.visitInsn(DUP); + mv.visitVarInsn(ASTORE, 3); + Label l13 = new Label(); + mv.visitJumpInsn(IFNONNULL, l13); + mv.visitInsn(ICONST_0); + Label l14 = new Label(); + mv.visitJumpInsn(GOTO, l14); + mv.visitLabel(l13); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l12, l12, INTEGER, INTEGER, INTEGER}); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); + mv.visitLabel(l14); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l12, l12, INTEGER, INTEGER, INTEGER, INTEGER}); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitInsn(IADD); + mv.visitInsn(ICONST_0); + mv.visitInsn(ICONST_5); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(IMUL); + mv.visitIntInsn(BIPUSH, 7); + mv.visitInsn(IDIV); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(1357, l15); + mv.visitVarInsn(ALOAD, 0); + Label l16 = new Label(); + mv.visitLabel(l16); + mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "weakness", "Lnet/minecraft/potion/Potion;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitIntInsn(SIPUSH, 150); + mv.visitInsn(IMUL); + mv.visitVarInsn(ILOAD, 2); + mv.visitInsn(IMUL); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "weakness", "Lnet/minecraft/potion/Potion;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); + mv.visitInsn(DUP); + mv.visitVarInsn(ASTORE, 3); + Label l17 = new Label(); + mv.visitJumpInsn(IFNONNULL, l17); + mv.visitInsn(ICONST_0); + Label l18 = new Label(); + mv.visitJumpInsn(GOTO, l18); + mv.visitLabel(l17); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l16, l16, INTEGER, INTEGER, INTEGER}); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); + mv.visitLabel(l18); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l16, l16, INTEGER, INTEGER, INTEGER, INTEGER}); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitInsn(IADD); + mv.visitInsn(ICONST_0); + mv.visitInsn(ICONST_5); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(IMUL); + mv.visitIntInsn(BIPUSH, 7); + mv.visitInsn(IDIV); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(1358, l19); + mv.visitVarInsn(ALOAD, 0); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "hunger", "Lnet/minecraft/potion/Potion;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitIntInsn(SIPUSH, 130); + mv.visitInsn(IMUL); + mv.visitVarInsn(ILOAD, 2); + mv.visitInsn(IMUL); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "hunger", "Lnet/minecraft/potion/Potion;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); + mv.visitInsn(DUP); + mv.visitVarInsn(ASTORE, 3); + Label l21 = new Label(); + mv.visitJumpInsn(IFNONNULL, l21); + mv.visitInsn(ICONST_0); + Label l22 = new Label(); + mv.visitJumpInsn(GOTO, l22); + mv.visitLabel(l21); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l20, l20, INTEGER, INTEGER, INTEGER}); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); + mv.visitLabel(l22); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l20, l20, INTEGER, INTEGER, INTEGER, INTEGER}); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitInsn(IADD); + mv.visitInsn(ICONST_0); + mv.visitInsn(ICONST_5); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(IMUL); + mv.visitIntInsn(BIPUSH, 7); + mv.visitInsn(IDIV); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); + Label l23 = new Label(); + mv.visitLabel(l23); + mv.visitLineNumber(1359, l23); + mv.visitVarInsn(ALOAD, 0); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETSTATIC, "ic2/core/IC2Potion", "radiation", "Lic2/core/IC2Potion;"); + mv.visitFieldInsn(GETFIELD, "ic2/core/IC2Potion", "id", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitIntInsn(SIPUSH, 180); + mv.visitInsn(IMUL); + mv.visitVarInsn(ILOAD, 2); + mv.visitInsn(IMUL); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "potionTypes", "[Lnet/minecraft/potion/Potion;"); + mv.visitIntInsn(BIPUSH, 24); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); + mv.visitInsn(DUP); + mv.visitVarInsn(ASTORE, 3); + Label l25 = new Label(); + mv.visitJumpInsn(IFNONNULL, l25); + mv.visitInsn(ICONST_0); + Label l26 = new Label(); + mv.visitJumpInsn(GOTO, l26); + mv.visitLabel(l25); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l24, l24, INTEGER, INTEGER, INTEGER}); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); + mv.visitLabel(l26); + mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l24, l24, INTEGER, INTEGER, INTEGER, INTEGER}); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitInsn(IADD); + mv.visitInsn(ICONST_0); + mv.visitInsn(ICONST_5); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(IMUL); + mv.visitIntInsn(BIPUSH, 7); + mv.visitInsn(IDIV); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(1360, l27); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + mv.visitLabel(l1); + mv.visitLineNumber(1362, l1); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l28, 0); + mv.visitLocalVariable("aLevel", "I", null, l0, l28, 1); + mv.visitLocalVariable("aAmountOfItems", "I", null, l0, l28, 2); + mv.visitLocalVariable("tEffect", "Lnet/minecraft/potion/PotionEffect;", null, l3, l1, 3); + mv.visitMaxs(9, 4); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullFrostHazmat")){ + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullFrostHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1272, l0); + mv.visitInsn(ICONST_1); + mv.visitVarInsn(ISTORE, 1); + Label l1 = new Label(); + mv.visitLabel(l1); + Label l2 = new Label(); + mv.visitJumpInsn(GOTO, l2); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(1273, l3); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Frost", "(Lnet/minecraft/item/ItemStack;)Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1274, l5); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l4); + mv.visitLineNumber(1272, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2B); + mv.visitVarInsn(ISTORE, 1); + mv.visitLabel(l2); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_5); + mv.visitJumpInsn(IF_ICMPLT, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(1276, l6); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); + mv.visitLocalVariable("i", "B", null, l1, l6, 1); + mv.visitMaxs(2, 2); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullHeatHazmat")){ + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullHeatHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1280, l0); + mv.visitInsn(ICONST_1); + mv.visitVarInsn(ISTORE, 1); + Label l1 = new Label(); + mv.visitLabel(l1); + Label l2 = new Label(); + mv.visitJumpInsn(GOTO, l2); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(1281, l3); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Fire", "(Lnet/minecraft/item/ItemStack;)Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1282, l5); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l4); + mv.visitLineNumber(1280, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2B); + mv.visitVarInsn(ISTORE, 1); + mv.visitLabel(l2); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_5); + mv.visitJumpInsn(IF_ICMPLT, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(1284, l6); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); + mv.visitLocalVariable("i", "B", null, l1, l6, 1); + mv.visitMaxs(2, 2); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullBioHazmat")){ + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullBioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1288, l0); + mv.visitInsn(ICONST_1); + mv.visitVarInsn(ISTORE, 1); + Label l1 = new Label(); + mv.visitLabel(l1); + Label l2 = new Label(); + mv.visitJumpInsn(GOTO, l2); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(1289, l3); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Biohazard", "(Lnet/minecraft/item/ItemStack;)Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1290, l5); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l4); + mv.visitLineNumber(1288, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2B); + mv.visitVarInsn(ISTORE, 1); + mv.visitLabel(l2); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_5); + mv.visitJumpInsn(IF_ICMPLT, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(1292, l6); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); + mv.visitLocalVariable("i", "B", null, l1, l6, 1); + mv.visitMaxs(2, 2); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullRadioHazmat")){ + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullRadioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1296, l0); + mv.visitInsn(ICONST_1); + mv.visitVarInsn(ISTORE, 1); + Label l1 = new Label(); + mv.visitLabel(l1); + Label l2 = new Label(); + mv.visitJumpInsn(GOTO, l2); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(1297, l3); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Radiation", "(Lnet/minecraft/item/ItemStack;)Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1298, l5); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l4); + mv.visitLineNumber(1296, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2B); + mv.visitVarInsn(ISTORE, 1); + mv.visitLabel(l2); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_5); + mv.visitJumpInsn(IF_ICMPLT, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(1300, l6); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); + mv.visitLocalVariable("i", "B", null, l1, l6, 1); + mv.visitMaxs(2, 2); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullElectroHazmat")){ + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullElectroHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1304, l0); + mv.visitInsn(ICONST_1); + mv.visitVarInsn(ISTORE, 1); + Label l1 = new Label(); + mv.visitLabel(l1); + Label l2 = new Label(); + mv.visitJumpInsn(GOTO, l2); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(1305, l3); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Electricity", "(Lnet/minecraft/item/ItemStack;)Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1306, l5); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l4); + mv.visitLineNumber(1304, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2B); + mv.visitVarInsn(ISTORE, 1); + mv.visitLabel(l2); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_5); + mv.visitJumpInsn(IF_ICMPLT, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(1308, l6); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); + mv.visitLocalVariable("i", "B", null, l1, l6, 1); + mv.visitMaxs(2, 2); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullGasHazmat")){ + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullGasHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1312, l0); + mv.visitInsn(ICONST_1); + mv.visitVarInsn(ISTORE, 1); + Label l1 = new Label(); + mv.visitLabel(l1); + Label l2 = new Label(); + mv.visitJumpInsn(GOTO, l2); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(1313, l3); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Gas", "(Lnet/minecraft/item/ItemStack;)Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1314, l5); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l4); + mv.visitLineNumber(1312, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2B); + mv.visitVarInsn(ISTORE, 1); + mv.visitLabel(l2); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ICONST_5); + mv.visitJumpInsn(IF_ICMPLT, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(1316, l6); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); + mv.visitLocalVariable("i", "B", null, l1, l6, 1); + mv.visitMaxs(2, 2); + mv.visitEnd(); + didInject = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Method injection complete."); return didInject; } @@ -104,7 +732,29 @@ public class ClassTransformer_GT_Utility { if (name.equals("getTier")) { methodVisitor = null; - } else { + } + else if (name.equals("applyRadioactivity")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullFrostHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullHeatHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullBioHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullRadioHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullElectroHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullGasHazmat")){ + methodVisitor = null; + } + else { methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java index 52e4d7d99d..10f04e7a48 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java @@ -3,11 +3,7 @@ package gtPlusPlus.preloader.asm.transformers; import static org.objectweb.asm.Opcodes.*; 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 org.objectweb.asm.*; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gtPlusPlus.core.util.minecraft.HazmatUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 1cb499479f..7c1b854770 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -53,6 +53,7 @@ import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricButcherKnife; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricLighter; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricSnips; import gtPlusPlus.xmod.gregtech.loaders.ProcessingToolHeadChoocher; +import gtPlusPlus.xmod.gregtech.loaders.misc.AddCustomMachineToPA; import gtPlusPlus.xmod.gregtech.loaders.misc.WoodCentrifuging; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; @@ -129,6 +130,9 @@ public class HANDLER_GT { if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ OldCircuitHandler.postInit(); } + + // Register custom singles to the PA + AddCustomMachineToPA.register(); // Register the No-Bonus Special Behaviour. diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java new file mode 100644 index 0000000000..321cab4628 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.lang.reflect.Method; + +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class AddCustomMachineToPA { + + private static final boolean sDoesPatchExist; + private static final Class sManagerPA; + private static final Method sRegisterRecipeMapForMeta; + + static { + sDoesPatchExist = ReflectionUtils.doesClassExist("gregtech.api.util.GT_ProcessingArray_Manager"); + if (sDoesPatchExist) { + sManagerPA = ReflectionUtils.getClass("gregtech.api.util.GT_ProcessingArray_Manager"); + sRegisterRecipeMapForMeta = ReflectionUtils.getMethod(sManagerPA, "registerRecipeMapForMeta", int.class, GT_Recipe_Map.class); + } + else { + sManagerPA = null; + sRegisterRecipeMapForMeta = null; + } + } + + public static final void registerRecipeMapForID(int aID, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {aID, aMap}); + } + + } + + public static final void registerRecipeMapBetweenRangeOfIDs(int aMin, int aMax, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + for (int i=aMin; i<=aMax;i++) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {i, aMap}); + //GT_ProcessingArray_Manager.registerRecipeMapForMeta(i, aMap); + } + } + } + + public static void register() { + + // Simple Washers + registerRecipeMapForID(767, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + registerRecipeMapBetweenRangeOfIDs(31017, 31020, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + + } + +} -- cgit From 0c0c4eba9a8a99687c4d157d1658976871bba047 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 9 Apr 2020 11:38:41 +0100 Subject: $ Fixed Hazmat ASM not actually injecting replacement methods. --- .../core/util/minecraft/HazmatUtils.java | 4 - .../transformers/ClassTransformer_GT_Utility.java | 31 +- .../production/GregtechMTE_FrothFlotationCell.java | 513 +++++++++++++++++++++ .../production/GregtechMTE_FrothFlotationPond.java | 513 --------------------- .../registration/gregtech/GregtechIsaMill.java | 4 +- 5 files changed, 537 insertions(+), 528 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationPond.java (limited to 'src/Java/gtPlusPlus/preloader/asm/transformers') diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index 1bb4c53bd2..fc017199b1 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -6,7 +6,6 @@ import java.lang.reflect.Field; import java.util.HashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gregtech.api.GregTech_API; import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Utility; @@ -30,8 +29,6 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class HazmatUtils { public static final GT_HashSet sHazmatList = new GT_HashSet(); - - private static final HashMap aIgnoreNBTMap = new HashMap(); private static final HashMap> mToolTips = new HashMap>(); @@ -305,7 +302,6 @@ public class HazmatUtils { return false; } } - aIgnoreNBTMap.put(aVanStack.getItem(), true); Logger.INFO("[Hazmat] Protection added for all 6 damage types, registering to master Hazmat list."); sHazmatList.add(aStack); return true; 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 3381518c1f..48493a739e 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java @@ -9,8 +9,8 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; -import cpw.mods.fml.relauncher.FMLRelaunchLog; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.preloader.Preloader_Logger; public class ClassTransformer_GT_Utility { @@ -35,14 +35,20 @@ public class ClassTransformer_GT_Utility { isValid = false; } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Valid patch? " + isValid + "."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Valid patch? " + isValid + "."); reader = aTempReader; writer = aTempWriter; if (reader != null && writer != null) { - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Attempting Method Injection."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Attempting Method Injection."); injectMethod("getTier"); - injectMethod("applyRadioactivity"); + injectMethod("applyRadioactivity"); + injectMethod("isWearingFullFrostHazmat"); + injectMethod("isWearingFullHeatHazmat"); + injectMethod("isWearingFullBioHazmat"); + injectMethod("isWearingFullRadioHazmat"); + injectMethod("isWearingFullElectroHazmat"); + injectMethod("isWearingFullGasHazmat"); } } @@ -63,9 +69,9 @@ public class ClassTransformer_GT_Utility { MethodVisitor mv; boolean didInject = false; ClassWriter cw = getWriter(); - String aClassNameFormatted = Utils.class.getName().replace(".", "/"); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassNameFormatted+"."); + String aClassNameFormatted = Utils.class.getName().replace(".", "/"); if (aMethodName.equals("getTier")) { + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassNameFormatted+"."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getTier", "(J)B", null, null); mv.visitCode(); Label l0 = new Label(); @@ -82,6 +88,7 @@ public class ClassTransformer_GT_Utility { didInject = true; } if (aMethodName.equals("applyRadioactivity")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "applyRadioactivity", "(Lnet/minecraft/entity/EntityLivingBase;II)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -390,6 +397,7 @@ public class ClassTransformer_GT_Utility { } if (aMethodName.equals("isWearingFullFrostHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullFrostHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -444,6 +452,7 @@ public class ClassTransformer_GT_Utility { } if (aMethodName.equals("isWearingFullHeatHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullHeatHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -498,6 +507,7 @@ public class ClassTransformer_GT_Utility { } if (aMethodName.equals("isWearingFullBioHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullBioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -552,6 +562,7 @@ public class ClassTransformer_GT_Utility { } if (aMethodName.equals("isWearingFullRadioHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullRadioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -606,6 +617,7 @@ public class ClassTransformer_GT_Utility { } if (aMethodName.equals("isWearingFullElectroHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullElectroHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -660,6 +672,7 @@ public class ClassTransformer_GT_Utility { } if (aMethodName.equals("isWearingFullGasHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullGasHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -713,7 +726,7 @@ public class ClassTransformer_GT_Utility { didInject = true; } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Method injection complete."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Method injection complete."); return didInject; } @@ -759,8 +772,8 @@ public class ClassTransformer_GT_Utility { } if (methodVisitor == null) { - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, - "Found method " + name + ", removing."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Found method " + name + ", removing."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Descriptor: "+desc); } return methodVisitor; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java new file mode 100644 index 0000000000..74047e5ecc --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java @@ -0,0 +1,513 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase { + + private int mLevel = -1; + + public GregtechMTE_FrothFlotationCell(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_FrothFlotationCell(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_FrothFlotationCell(this.mName); + } + + @Override + public String getMachineType() { + return "Flotation Cell"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Grows Algae!", + "Controller Block for the Algae Farm", + "Provide compost to boost production by one tier", + "Size: 9x3x9 [WxHxL] (open)", + "X X", + "X X", + "XXXXXXXXX", + "Machine Casings (all bottom layer)", + "Sterile Farm Casings (rest)", + "Controller (front centered)", + "All hatches must be on the bottom layer", + "All hulls must be the same tier, this dictates machine speed", + "Does not require power or maintenance", + "1x Output Bus", + "1x Input Bus (optional)", + "1x Input Hatch (fill with water)", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + + @Override + public boolean isFacingValid(final byte aFacing) { + Logger.INFO("Facing: "+aFacing); + return aFacing == 1; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + int aID = TAE.getIndexFromPage(2, 1); + + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public int getMaxParallelRecipes() { + return 2; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + + + this.mLevel = 0; + if (this.mLevel == 0) { + return false; + } + + // Get Facing direction + int mCurrentDirectionX; + int mCurrentDirectionZ; + + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + // Get Expected Tier +// Block aCasingBlock = aBaseMetaTileEntity.getBlockAtSide((byte) 3); +// int aCasingMeta = aBaseMetaTileEntity.getMetaIDAtSide((byte) 3); +// +// // Bad Casings +// if ((aCasingBlock != GregTech_API.sBlockCasings1) || aCasingMeta > 9) { +// Logger.INFO("is false"); +// return false; +// } +// else { + mLevel = this.getCasingTier(); + //} + int aID = TAE.getIndexFromPage(1, 15); + int tAmount = 0; + check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) { + for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) { + for (int h = -1; h < 2; ++h) { + if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+aID); + if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, aID)) { + continue; + } + else if (h != -1 && tTileEntity != null) { + Logger.INFO("Found hatch in wrong place, expected casing."); + return false; + } + + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + + if ((h >= 0) && (tBlock == ModBlocks.blockCasings2Misc) && (tMeta == 15) ) { + ++tAmount; + } + else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta == mLevel) ) { + ++tAmount; + } + else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta != mLevel) ) { + Logger.INFO("Found wrong tiered casing."); + return false; + } + else { + if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper + && j != mOffsetZ_Upper) && (h == 0 || h == 1)) { + continue; + } else { + if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water + || tBlock == Blocks.flowing_water + || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + continue; + + } else { + Logger.INFO("[x] Did not form - Found: " + tBlock.getLocalizedName() + " | " + + tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), + aBaseMetaTileEntity.getXCoord() + i, + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord() + j) + + " | Special Meta: " + + (tTileEntity == null ? "0" : tTileEntity.getMetaTileID())); + Logger.INFO("[x] Did not form - Found: " + + (aBaseMetaTileEntity.getXCoord() + xDir + i) + " | " + + aBaseMetaTileEntity.getYCoord() + " | " + + (aBaseMetaTileEntity.getZCoord() + zDir + j)); + break check; + } + } + + } + + } + } + } + } + if ((tAmount >= 64)) { + Logger.INFO("Made structure."); + this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + } else { + Logger.INFO("Did not make structure."); + } + return (tAmount >= 64); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld().setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); + + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // Logger.INFO("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 60; + + if (isValidWater) { + Logger.INFO("Filled structure."); + return true; + } + else { + return false; + } + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + this.fixAllMaintenanceIssue(); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mLevel = getCasingTier(); + } + + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + if (this.mLevel < 0) { + Logger.INFO("Bad Tier."); + return false; + } + + if (!checkForWater()) { + Logger.INFO("Not enough Water."); + return false; + } + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + Logger.INFO("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); + + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + return false; + } + if (tRecipe.mInputs.length > 0) { + for (ItemStack aInputToConsume : tRecipe.mInputs) { + this.depleteInput(aInputToConsume); + } + } + + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + this.mMaxProgresstime = (int)(tRecipe.mDuration); + this.mEUt = 0; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + Logger.INFO("Recipe time: "+this.mMaxProgresstime); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= aMaxParallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < aMaxParallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List splitStacks = new ArrayList(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List tSList = new ArrayList(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.INFO("GOOD RETURN - 1"); + return true; + + } + + private boolean isUsingCompost(ItemStack[] aItemInputs) { + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); + for (ItemStack i : aItemInputs) { + if (GT_Utility.areStacksEqual(aCompost, i)) { + if (i.stackSize >= 8) { + return true; + } + else { + continue; + } + } + } + return false; + } + + + private final int getCasingTier() { + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); + if (aInitStructureCheck == GregTech_API.sBlockCasings1) { + return aInitStructureCheckMeta; + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationPond.java deleted file mode 100644 index b04a068376..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationPond.java +++ /dev/null @@ -1,513 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.TAE; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.item.chemistry.AgriculturalChem; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; -import ic2.core.init.BlocksItems; -import ic2.core.init.InternalName; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -public class GregtechMTE_FrothFlotationPond extends GregtechMeta_MultiBlockBase { - - private int mLevel = -1; - - public GregtechMTE_FrothFlotationPond(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMTE_FrothFlotationPond(final String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMTE_FrothFlotationPond(this.mName); - } - - @Override - public String getMachineType() { - return "Algae Pond"; - } - - @Override - public String[] getTooltip() { - return new String[] { - "Grows Algae!", - "Controller Block for the Algae Farm", - "Provide compost to boost production by one tier", - "Size: 9x3x9 [WxHxL] (open)", - "X X", - "X X", - "XXXXXXXXX", - "Machine Casings (all bottom layer)", - "Sterile Farm Casings (rest)", - "Controller (front centered)", - "All hatches must be on the bottom layer", - "All hulls must be the same tier, this dictates machine speed", - "Does not require power or maintenance", - "1x Output Bus", - "1x Input Bus (optional)", - "1x Input Hatch (fill with water)", - }; - } - - @Override - public String getSound() { - return GregTech_API.sSoundList.get(Integer.valueOf(207)); - } - - - @Override - public boolean isFacingValid(final byte aFacing) { - Logger.INFO("Facing: "+aFacing); - return aFacing == 1; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - - int aID = TAE.getIndexFromPage(2, 1); - - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]}; - } - - @Override - public boolean hasSlotInGUI() { - return true; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - @Override - public int getMaxParallelRecipes() { - return 2; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - - - this.mLevel = 0; - if (this.mLevel == 0) { - return false; - } - - // Get Facing direction - int mCurrentDirectionX; - int mCurrentDirectionZ; - - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - mCurrentDirectionX = 4; - mCurrentDirectionZ = 4; - - mOffsetX_Lower = -4; - mOffsetX_Upper = 4; - mOffsetZ_Lower = -4; - mOffsetZ_Upper = 4; - - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX - * mCurrentDirectionX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ - * mCurrentDirectionZ; - - // Get Expected Tier -// Block aCasingBlock = aBaseMetaTileEntity.getBlockAtSide((byte) 3); -// int aCasingMeta = aBaseMetaTileEntity.getMetaIDAtSide((byte) 3); -// -// // Bad Casings -// if ((aCasingBlock != GregTech_API.sBlockCasings1) || aCasingMeta > 9) { -// Logger.INFO("is false"); -// return false; -// } -// else { - mLevel = this.getCasingTier(); - //} - int aID = TAE.getIndexFromPage(1, 15); - int tAmount = 0; - check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) { - for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) { - for (int h = -1; h < 2; ++h) { - if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - - Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+aID); - if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, aID)) { - continue; - } - else if (h != -1 && tTileEntity != null) { - Logger.INFO("Found hatch in wrong place, expected casing."); - return false; - } - - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - - if ((h >= 0) && (tBlock == ModBlocks.blockCasings2Misc) && (tMeta == 15) ) { - ++tAmount; - } - else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta == mLevel) ) { - ++tAmount; - } - else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta != mLevel) ) { - Logger.INFO("Found wrong tiered casing."); - return false; - } - else { - if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper - && j != mOffsetZ_Upper) && (h == 0 || h == 1)) { - continue; - } else { - if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water - || tBlock == Blocks.flowing_water - || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { - continue; - - } else { - Logger.INFO("[x] Did not form - Found: " + tBlock.getLocalizedName() + " | " - + tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), - aBaseMetaTileEntity.getXCoord() + i, - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord() + j) - + " | Special Meta: " - + (tTileEntity == null ? "0" : tTileEntity.getMetaTileID())); - Logger.INFO("[x] Did not form - Found: " - + (aBaseMetaTileEntity.getXCoord() + xDir + i) + " | " - + aBaseMetaTileEntity.getYCoord() + " | " - + (aBaseMetaTileEntity.getZCoord() + zDir + j)); - break check; - } - } - - } - - } - } - } - } - if ((tAmount >= 64)) { - Logger.INFO("Made structure."); - this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); - } else { - Logger.INFO("Did not make structure."); - } - return (tAmount >= 64); - } - - public boolean checkForWater() { - - // Get Facing direction - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - mCurrentDirectionX = 4; - mCurrentDirectionZ = 4; - - mOffsetX_Lower = -4; - mOffsetX_Upper = 4; - mOffsetZ_Lower = -4; - mOffsetZ_Upper = 4; - - // if (aBaseMetaTileEntity.fac) - - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX - * mCurrentDirectionX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ - * mCurrentDirectionZ; - - int tAmount = 0; - for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { - for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { - for (int h = 0; h < 2; h++) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { - if (this.getStoredFluids() != null) { - for (FluidStack stored : this.getStoredFluids()) { - if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { - if (stored.amount >= 1000) { - // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); - stored.amount -= 1000; - Block fluidUsed = Blocks.water; - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getXCoord() + xDir + i, - aBaseMetaTileEntity.getYCoord() + h, - aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); - - } - } - } - } - } - tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { - ++tAmount; - // Logger.INFO("Found Water"); - } - } - } - } - - boolean isValidWater = tAmount >= 60; - - if (isValidWater) { - Logger.INFO("Filled structure."); - return true; - } - else { - return false; - } - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public String getCustomGUIResourceName() { - return null; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - this.fixAllMaintenanceIssue(); - // Silly Client Syncing - if (aBaseMetaTileEntity.isClientSide()) { - this.mLevel = getCasingTier(); - } - - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); - } - - public boolean checkRecipeGeneric( - ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, int aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - if (this.mLevel < 0) { - Logger.INFO("Bad Tier."); - return false; - } - - if (!checkForWater()) { - Logger.INFO("Not enough Water."); - return false; - } - - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - - Logger.INFO("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); - - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); - if (aMaxParallelRecipes == 0) { - return false; - } - if (tRecipe.mInputs.length > 0) { - for (ItemStack aInputToConsume : tRecipe.mInputs) { - this.depleteInput(aInputToConsume); - } - } - - - // -- Try not to fail after this point - inputs have already been consumed! -- - - - this.mMaxProgresstime = (int)(tRecipe.mDuration); - this.mEUt = 0; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - Logger.INFO("Recipe time: "+this.mMaxProgresstime); - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; - for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { - if (tRecipe.getFluidOutput(h) != null) { - tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); - tOutputFluids[h].amount *= aMaxParallelRecipes; - } - } - - // Collect output item types - ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOutputItems[h] = tRecipe.getOutput(h).copy(); - tOutputItems[h].stackSize = 0; - } - } - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < aMaxParallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List splitStacks = new ArrayList(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List tSList = new ArrayList(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - Logger.INFO("GOOD RETURN - 1"); - return true; - - } - - private boolean isUsingCompost(ItemStack[] aItemInputs) { - ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); - for (ItemStack i : aItemInputs) { - if (GT_Utility.areStacksEqual(aCompost, i)) { - if (i.stackSize >= 8) { - return true; - } - else { - continue; - } - } - } - return false; - } - - - private final int getCasingTier() { - if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { - return 0; - } - try { - Block aInitStructureCheck; - int aInitStructureCheckMeta; - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); - aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); - if (aInitStructureCheck == GregTech_API.sBlockCasings1) { - return aInitStructureCheckMeta; - } - return 0; - } - catch (Throwable t) { - t.printStackTrace(); - return 0; - } - } - - - -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java index 8719061f7c..19c361be93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java @@ -4,7 +4,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IsaMill; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_FrothFlotationPond; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_FrothFlotationCell; public class GregtechIsaMill { @@ -13,7 +13,7 @@ public class GregtechIsaMill { Logger.INFO("Gregtech5u Content | Registering Milling Content."); GregtechItemList.Controller_IsaMill.set(new GregtechMetaTileEntity_IsaMill(31027, "gtpp.multimachine.isamill", "IsaMill Grinding Machine").getStackForm(1L)); - GregtechItemList.Controller_Flotation_Cell.set(new GregtechMTE_FrothFlotationPond(31028, "gtpp.multimachine.flotationcell", "Flotation Cell Regulator").getStackForm(1L)); + GregtechItemList.Controller_Flotation_Cell.set(new GregtechMTE_FrothFlotationCell(31028, "gtpp.multimachine.flotationcell", "Flotation Cell Regulator").getStackForm(1L)); // Milling Ball Bus GregtechItemList.Bus_Milling_Balls.set((new GT_MetaTileEntity_Hatch_MillingBalls(31029, "hatch.milling", "Ball Housing")).getStackForm(1L)); -- cgit From ddeb9c0c0fc4da536a291aee51019c0d2dd824f8 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 10 Apr 2020 11:26:47 +0100 Subject: $ More work overhauling GT/IC2 Hazmat system. --- .../core/util/minecraft/EnergyUtils.java | 7 +- .../core/util/minecraft/EntityUtils.java | 71 ++- .../core/util/minecraft/HazmatUtils.java | 2 +- .../preloader/asm/Preloader_FMLLoadingPlugin.java | 2 + .../transformers/ClassTransformer_GT_Utility.java | 663 +++------------------ 5 files changed, 156 insertions(+), 589 deletions(-) (limited to 'src/Java/gtPlusPlus/preloader/asm/transformers') diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java index 7daefbcc23..8b02ea9c7c 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java @@ -1,17 +1,20 @@ package gtPlusPlus.core.util.minecraft; import gregtech.api.util.GT_ModHandler; -import gtPlusPlus.api.objects.Logger; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; import ic2.api.item.ISpecialElectricItem; +import net.minecraft.item.ItemRedstone; import net.minecraft.item.ItemStack; public class EnergyUtils { public static class EU { - public static boolean isElectricItem(ItemStack aStack) { + public static boolean isElectricItem(ItemStack aStack) { + if (aStack == null || aStack.getItem() == null || aStack.getItem() instanceof ItemRedstone) { + return false; + } if (aStack.getItem() instanceof ISpecialElectricItem) { return true; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java index 66f9e2453d..fda7b0b738 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java @@ -16,12 +16,11 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.IC2Potion; import ic2.core.item.armor.ItemArmorHazmat; import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -103,7 +102,7 @@ public class EntityUtils { duration = radiationLevel*30; } //IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); - GT_Utility.applyRadioactivity(entityLiving, radiationLevel, stackSize); + applyRadioactivity(entityLiving, radiationLevel, stackSize); } } } @@ -111,6 +110,68 @@ public class EntityUtils { } return false; } + + public static boolean isWearingFullFrostHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Frost(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullHeatHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Fire(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullBioHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Biohazard(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullRadioHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Radiation(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullElectroHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Electricity(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullGasHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Gas(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean applyRadioactivity(EntityLivingBase aEntity, int aLevel, int aAmountOfItems) { + if (aLevel > 0 && aEntity != null && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD && !ItemArmorHazmat.hasCompleteHazmat(aEntity)) { + PotionEffect tEffect = null; + aEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, aLevel * 140 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.confusion.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.weakness.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.hunger.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(IC2Potion.radiation.id, aLevel * 180 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + return true; + } + return false; + } public static boolean applyHeatDamageToEntity(final int heatLevel, final World world, final Entity entityHolding){ if (!world.isRemote){ diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index fc017199b1..f0b93a32dc 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -385,7 +385,7 @@ public class HazmatUtils { return true; } for (GT_ItemStack o : aSet) { - if (o != null) { + if (o != null && o.mItem != null && aStack != null && aStack.getItem() != null) { if (GT_Utility.areStacksEqual(o.toStack(), aStack, true)) { return true; } diff --git a/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java b/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java index 46196cb87f..8aa449df5d 100644 --- a/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java +++ b/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java @@ -13,6 +13,8 @@ import net.minecraft.launchwrapper.Launch; @SortingIndex(10097) @MCVersion(value = "1.7.10") +@IFMLLoadingPlugin.TransformerExclusions("gtPlusPlus.preloader") +@IFMLLoadingPlugin.Name(CORE_Preloader.NAME) public class Preloader_FMLLoadingPlugin implements IFMLLoadingPlugin { //-Dfml.coreMods.load=gtPlusPlus.preloader.asm.Preloader_FMLLoadingPlugin 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 48493a739e..fa711e5693 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java @@ -11,6 +11,12 @@ import org.objectweb.asm.MethodVisitor; import gtPlusPlus.core.util.Utils; import gtPlusPlus.preloader.Preloader_Logger; +import ic2.core.IC2Potion; +import ic2.core.item.armor.ItemArmorHazmat; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; public class ClassTransformer_GT_Utility { @@ -18,6 +24,8 @@ public class ClassTransformer_GT_Utility { private final ClassReader reader; private final ClassWriter writer; private final String className; + + public ClassTransformer_GT_Utility(byte[] basicClass, String aClassName) { @@ -69,332 +77,7 @@ public class ClassTransformer_GT_Utility { MethodVisitor mv; boolean didInject = false; ClassWriter cw = getWriter(); - String aClassNameFormatted = Utils.class.getName().replace(".", "/"); - if (aMethodName.equals("getTier")) { - Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassNameFormatted+"."); - mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getTier", "(J)B", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(23, l0); - mv.visitVarInsn(LLOAD, 0); - mv.visitMethodInsn(INVOKESTATIC, aClassNameFormatted, "getTier", "(J)B", false); - mv.visitInsn(IRETURN); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLocalVariable("l", "J", null, l0, l1, 0); - mv.visitMaxs(2, 2); - mv.visitEnd(); - didInject = true; - } - if (aMethodName.equals("applyRadioactivity")){ - Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); - mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "applyRadioactivity", "(Lnet/minecraft/entity/EntityLivingBase;II)Z", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(1352, l0); - mv.visitVarInsn(ILOAD, 1); - Label l1 = new Label(); - mv.visitJumpInsn(IFLE, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitJumpInsn(IFNULL, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getCreatureAttribute", "()Lnet/minecraft/entity/EnumCreatureAttribute;", false); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/entity/EnumCreatureAttribute", "UNDEAD", "Lnet/minecraft/entity/EnumCreatureAttribute;"); - mv.visitJumpInsn(IF_ACMPEQ, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getCreatureAttribute", "()Lnet/minecraft/entity/EnumCreatureAttribute;", false); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/entity/EnumCreatureAttribute", "ARTHROPOD", "Lnet/minecraft/entity/EnumCreatureAttribute;"); - mv.visitJumpInsn(IF_ACMPEQ, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESTATIC, "ic2/core/item/armor/ItemArmorHazmat", "hasCompleteHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); - mv.visitJumpInsn(IFNE, l1); - Label l2 = new Label(); - mv.visitLabel(l2); - mv.visitLineNumber(1353, l2); - mv.visitInsn(ACONST_NULL); - mv.visitVarInsn(ASTORE, 3); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLineNumber(1354, l3); - mv.visitVarInsn(ALOAD, 0); - Label l4 = new Label(); - mv.visitLabel(l4); - mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); - mv.visitInsn(DUP); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "moveSlowdown", "Lnet/minecraft/potion/Potion;"); - mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); - mv.visitVarInsn(ILOAD, 1); - mv.visitIntInsn(SIPUSH, 140); - mv.visitInsn(IMUL); - mv.visitVarInsn(ILOAD, 2); - mv.visitInsn(IMUL); - mv.visitInsn(ICONST_0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "moveSlowdown", "Lnet/minecraft/potion/Potion;"); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); - mv.visitInsn(DUP); - mv.visitVarInsn(ASTORE, 3); - Label l5 = new Label(); - mv.visitJumpInsn(IFNONNULL, l5); - mv.visitInsn(ICONST_0); - Label l6 = new Label(); - mv.visitJumpInsn(GOTO, l6); - mv.visitLabel(l5); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l4, l4, INTEGER, INTEGER, INTEGER}); - mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); - mv.visitLabel(l6); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l4, l4, INTEGER, INTEGER, INTEGER, INTEGER}); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitInsn(IADD); - mv.visitInsn(ICONST_0); - mv.visitInsn(ICONST_5); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(IMUL); - mv.visitIntInsn(BIPUSH, 7); - mv.visitInsn(IDIV); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLineNumber(1355, l7); - mv.visitVarInsn(ALOAD, 0); - Label l8 = new Label(); - mv.visitLabel(l8); - mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); - mv.visitInsn(DUP); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "digSlowdown", "Lnet/minecraft/potion/Potion;"); - mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); - mv.visitVarInsn(ILOAD, 1); - mv.visitIntInsn(SIPUSH, 150); - mv.visitInsn(IMUL); - mv.visitVarInsn(ILOAD, 2); - mv.visitInsn(IMUL); - mv.visitInsn(ICONST_0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "digSlowdown", "Lnet/minecraft/potion/Potion;"); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); - mv.visitInsn(DUP); - mv.visitVarInsn(ASTORE, 3); - Label l9 = new Label(); - mv.visitJumpInsn(IFNONNULL, l9); - mv.visitInsn(ICONST_0); - Label l10 = new Label(); - mv.visitJumpInsn(GOTO, l10); - mv.visitLabel(l9); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l8, l8, INTEGER, INTEGER, INTEGER}); - mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); - mv.visitLabel(l10); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l8, l8, INTEGER, INTEGER, INTEGER, INTEGER}); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitInsn(IADD); - mv.visitInsn(ICONST_0); - mv.visitInsn(ICONST_5); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(IMUL); - mv.visitIntInsn(BIPUSH, 7); - mv.visitInsn(IDIV); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); - Label l11 = new Label(); - mv.visitLabel(l11); - mv.visitLineNumber(1356, l11); - mv.visitVarInsn(ALOAD, 0); - Label l12 = new Label(); - mv.visitLabel(l12); - mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); - mv.visitInsn(DUP); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "confusion", "Lnet/minecraft/potion/Potion;"); - mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); - mv.visitVarInsn(ILOAD, 1); - mv.visitIntInsn(SIPUSH, 130); - mv.visitInsn(IMUL); - mv.visitVarInsn(ILOAD, 2); - mv.visitInsn(IMUL); - mv.visitInsn(ICONST_0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "confusion", "Lnet/minecraft/potion/Potion;"); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); - mv.visitInsn(DUP); - mv.visitVarInsn(ASTORE, 3); - Label l13 = new Label(); - mv.visitJumpInsn(IFNONNULL, l13); - mv.visitInsn(ICONST_0); - Label l14 = new Label(); - mv.visitJumpInsn(GOTO, l14); - mv.visitLabel(l13); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l12, l12, INTEGER, INTEGER, INTEGER}); - mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); - mv.visitLabel(l14); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l12, l12, INTEGER, INTEGER, INTEGER, INTEGER}); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitInsn(IADD); - mv.visitInsn(ICONST_0); - mv.visitInsn(ICONST_5); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(IMUL); - mv.visitIntInsn(BIPUSH, 7); - mv.visitInsn(IDIV); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); - Label l15 = new Label(); - mv.visitLabel(l15); - mv.visitLineNumber(1357, l15); - mv.visitVarInsn(ALOAD, 0); - Label l16 = new Label(); - mv.visitLabel(l16); - mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); - mv.visitInsn(DUP); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "weakness", "Lnet/minecraft/potion/Potion;"); - mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); - mv.visitVarInsn(ILOAD, 1); - mv.visitIntInsn(SIPUSH, 150); - mv.visitInsn(IMUL); - mv.visitVarInsn(ILOAD, 2); - mv.visitInsn(IMUL); - mv.visitInsn(ICONST_0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "weakness", "Lnet/minecraft/potion/Potion;"); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); - mv.visitInsn(DUP); - mv.visitVarInsn(ASTORE, 3); - Label l17 = new Label(); - mv.visitJumpInsn(IFNONNULL, l17); - mv.visitInsn(ICONST_0); - Label l18 = new Label(); - mv.visitJumpInsn(GOTO, l18); - mv.visitLabel(l17); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l16, l16, INTEGER, INTEGER, INTEGER}); - mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); - mv.visitLabel(l18); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l16, l16, INTEGER, INTEGER, INTEGER, INTEGER}); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitInsn(IADD); - mv.visitInsn(ICONST_0); - mv.visitInsn(ICONST_5); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(IMUL); - mv.visitIntInsn(BIPUSH, 7); - mv.visitInsn(IDIV); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); - Label l19 = new Label(); - mv.visitLabel(l19); - mv.visitLineNumber(1358, l19); - mv.visitVarInsn(ALOAD, 0); - Label l20 = new Label(); - mv.visitLabel(l20); - mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); - mv.visitInsn(DUP); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "hunger", "Lnet/minecraft/potion/Potion;"); - mv.visitFieldInsn(GETFIELD, "net/minecraft/potion/Potion", "id", "I"); - mv.visitVarInsn(ILOAD, 1); - mv.visitIntInsn(SIPUSH, 130); - mv.visitInsn(IMUL); - mv.visitVarInsn(ILOAD, 2); - mv.visitInsn(IMUL); - mv.visitInsn(ICONST_0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "hunger", "Lnet/minecraft/potion/Potion;"); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); - mv.visitInsn(DUP); - mv.visitVarInsn(ASTORE, 3); - Label l21 = new Label(); - mv.visitJumpInsn(IFNONNULL, l21); - mv.visitInsn(ICONST_0); - Label l22 = new Label(); - mv.visitJumpInsn(GOTO, l22); - mv.visitLabel(l21); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l20, l20, INTEGER, INTEGER, INTEGER}); - mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); - mv.visitLabel(l22); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l20, l20, INTEGER, INTEGER, INTEGER, INTEGER}); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitInsn(IADD); - mv.visitInsn(ICONST_0); - mv.visitInsn(ICONST_5); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(IMUL); - mv.visitIntInsn(BIPUSH, 7); - mv.visitInsn(IDIV); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); - Label l23 = new Label(); - mv.visitLabel(l23); - mv.visitLineNumber(1359, l23); - mv.visitVarInsn(ALOAD, 0); - Label l24 = new Label(); - mv.visitLabel(l24); - mv.visitTypeInsn(NEW, "net/minecraft/potion/PotionEffect"); - mv.visitInsn(DUP); - mv.visitFieldInsn(GETSTATIC, "ic2/core/IC2Potion", "radiation", "Lic2/core/IC2Potion;"); - mv.visitFieldInsn(GETFIELD, "ic2/core/IC2Potion", "id", "I"); - mv.visitVarInsn(ILOAD, 1); - mv.visitIntInsn(SIPUSH, 180); - mv.visitInsn(IMUL); - mv.visitVarInsn(ILOAD, 2); - mv.visitInsn(IMUL); - mv.visitInsn(ICONST_0); - mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETSTATIC, "net/minecraft/potion/Potion", "potionTypes", "[Lnet/minecraft/potion/Potion;"); - mv.visitIntInsn(BIPUSH, 24); - mv.visitInsn(AALOAD); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getActivePotionEffect", "(Lnet/minecraft/potion/Potion;)Lnet/minecraft/potion/PotionEffect;", false); - mv.visitInsn(DUP); - mv.visitVarInsn(ASTORE, 3); - Label l25 = new Label(); - mv.visitJumpInsn(IFNONNULL, l25); - mv.visitInsn(ICONST_0); - Label l26 = new Label(); - mv.visitJumpInsn(GOTO, l26); - mv.visitLabel(l25); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 6, new Object[] {"net/minecraft/entity/EntityLivingBase", l24, l24, INTEGER, INTEGER, INTEGER}); - mv.visitVarInsn(ALOAD, 3); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/potion/PotionEffect", "getDuration", "()I", false); - mv.visitLabel(l26); - mv.visitFrame(F_FULL, 4, new Object[] {"net/minecraft/entity/EntityLivingBase", INTEGER, INTEGER, "net/minecraft/potion/PotionEffect"}, 7, new Object[] {"net/minecraft/entity/EntityLivingBase", l24, l24, INTEGER, INTEGER, INTEGER, INTEGER}); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitInsn(IADD); - mv.visitInsn(ICONST_0); - mv.visitInsn(ICONST_5); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(IMUL); - mv.visitIntInsn(BIPUSH, 7); - mv.visitInsn(IDIV); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); - mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/potion/PotionEffect", "", "(III)V", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "addPotionEffect", "(Lnet/minecraft/potion/PotionEffect;)V", false); - Label l27 = new Label(); - mv.visitLabel(l27); - mv.visitLineNumber(1360, l27); - mv.visitInsn(ICONST_1); - mv.visitInsn(IRETURN); - mv.visitLabel(l1); - mv.visitLineNumber(1362, l1); - mv.visitFrame(F_CHOP,1, null, 0, null); - mv.visitInsn(ICONST_0); - mv.visitInsn(IRETURN); - Label l28 = new Label(); - mv.visitLabel(l28); - mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l28, 0); - mv.visitLocalVariable("aLevel", "I", null, l0, l28, 1); - mv.visitLocalVariable("aAmountOfItems", "I", null, l0, l28, 2); - mv.visitLocalVariable("tEffect", "Lnet/minecraft/potion/PotionEffect;", null, l3, l1, 3); - mv.visitMaxs(9, 4); - mv.visitEnd(); - didInject = true; - } + String aClassNameFormatted = Utils.class.getName().replace(".", "/"); if (aMethodName.equals("isWearingFullFrostHazmat")){ Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); @@ -402,51 +85,14 @@ public class ClassTransformer_GT_Utility { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); - mv.visitLineNumber(1272, l0); - mv.visitInsn(ICONST_1); - mv.visitVarInsn(ISTORE, 1); - Label l1 = new Label(); - mv.visitLabel(l1); - Label l2 = new Label(); - mv.visitJumpInsn(GOTO, l2); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLineNumber(1273, l3); - mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitLineNumber(1273, l0); mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Frost", "(Lnet/minecraft/item/ItemStack;)Z", false); - Label l4 = new Label(); - mv.visitJumpInsn(IFNE, l4); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLineNumber(1274, l5); - mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullFrostHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); mv.visitInsn(IRETURN); - mv.visitLabel(l4); - mv.visitLineNumber(1272, l4); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_1); - mv.visitInsn(IADD); - mv.visitInsn(I2B); - mv.visitVarInsn(ISTORE, 1); - mv.visitLabel(l2); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_5); - mv.visitJumpInsn(IF_ICMPLT, l3); - Label l6 = new Label(); - mv.visitLabel(l6); - mv.visitLineNumber(1276, l6); - mv.visitInsn(ICONST_1); - mv.visitInsn(IRETURN); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); - mv.visitLocalVariable("i", "B", null, l1, l6, 1); - mv.visitMaxs(2, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); mv.visitEnd(); didInject = true; } @@ -457,51 +103,14 @@ public class ClassTransformer_GT_Utility { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); - mv.visitLineNumber(1280, l0); - mv.visitInsn(ICONST_1); - mv.visitVarInsn(ISTORE, 1); - Label l1 = new Label(); - mv.visitLabel(l1); - Label l2 = new Label(); - mv.visitJumpInsn(GOTO, l2); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLineNumber(1281, l3); - mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitLineNumber(1277, l0); mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Fire", "(Lnet/minecraft/item/ItemStack;)Z", false); - Label l4 = new Label(); - mv.visitJumpInsn(IFNE, l4); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLineNumber(1282, l5); - mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullHeatHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); mv.visitInsn(IRETURN); - mv.visitLabel(l4); - mv.visitLineNumber(1280, l4); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_1); - mv.visitInsn(IADD); - mv.visitInsn(I2B); - mv.visitVarInsn(ISTORE, 1); - mv.visitLabel(l2); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_5); - mv.visitJumpInsn(IF_ICMPLT, l3); - Label l6 = new Label(); - mv.visitLabel(l6); - mv.visitLineNumber(1284, l6); - mv.visitInsn(ICONST_1); - mv.visitInsn(IRETURN); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); - mv.visitLocalVariable("i", "B", null, l1, l6, 1); - mv.visitMaxs(2, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); mv.visitEnd(); didInject = true; } @@ -512,51 +121,14 @@ public class ClassTransformer_GT_Utility { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); - mv.visitLineNumber(1288, l0); - mv.visitInsn(ICONST_1); - mv.visitVarInsn(ISTORE, 1); - Label l1 = new Label(); - mv.visitLabel(l1); - Label l2 = new Label(); - mv.visitJumpInsn(GOTO, l2); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLineNumber(1289, l3); - mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitLineNumber(1281, l0); mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Biohazard", "(Lnet/minecraft/item/ItemStack;)Z", false); - Label l4 = new Label(); - mv.visitJumpInsn(IFNE, l4); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLineNumber(1290, l5); - mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullBioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); mv.visitInsn(IRETURN); - mv.visitLabel(l4); - mv.visitLineNumber(1288, l4); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_1); - mv.visitInsn(IADD); - mv.visitInsn(I2B); - mv.visitVarInsn(ISTORE, 1); - mv.visitLabel(l2); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_5); - mv.visitJumpInsn(IF_ICMPLT, l3); - Label l6 = new Label(); - mv.visitLabel(l6); - mv.visitLineNumber(1292, l6); - mv.visitInsn(ICONST_1); - mv.visitInsn(IRETURN); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); - mv.visitLocalVariable("i", "B", null, l1, l6, 1); - mv.visitMaxs(2, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); mv.visitEnd(); didInject = true; } @@ -567,51 +139,14 @@ public class ClassTransformer_GT_Utility { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); - mv.visitLineNumber(1296, l0); - mv.visitInsn(ICONST_1); - mv.visitVarInsn(ISTORE, 1); - Label l1 = new Label(); - mv.visitLabel(l1); - Label l2 = new Label(); - mv.visitJumpInsn(GOTO, l2); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLineNumber(1297, l3); - mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitLineNumber(1285, l0); mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Radiation", "(Lnet/minecraft/item/ItemStack;)Z", false); - Label l4 = new Label(); - mv.visitJumpInsn(IFNE, l4); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLineNumber(1298, l5); - mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullRadioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); mv.visitInsn(IRETURN); - mv.visitLabel(l4); - mv.visitLineNumber(1296, l4); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_1); - mv.visitInsn(IADD); - mv.visitInsn(I2B); - mv.visitVarInsn(ISTORE, 1); - mv.visitLabel(l2); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_5); - mv.visitJumpInsn(IF_ICMPLT, l3); - Label l6 = new Label(); - mv.visitLabel(l6); - mv.visitLineNumber(1300, l6); - mv.visitInsn(ICONST_1); - mv.visitInsn(IRETURN); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); - mv.visitLocalVariable("i", "B", null, l1, l6, 1); - mv.visitMaxs(2, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); mv.visitEnd(); didInject = true; } @@ -622,51 +157,14 @@ public class ClassTransformer_GT_Utility { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); - mv.visitLineNumber(1304, l0); - mv.visitInsn(ICONST_1); - mv.visitVarInsn(ISTORE, 1); - Label l1 = new Label(); - mv.visitLabel(l1); - Label l2 = new Label(); - mv.visitJumpInsn(GOTO, l2); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLineNumber(1305, l3); - mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitLineNumber(1289, l0); mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Electricity", "(Lnet/minecraft/item/ItemStack;)Z", false); - Label l4 = new Label(); - mv.visitJumpInsn(IFNE, l4); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLineNumber(1306, l5); - mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullElectroHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); mv.visitInsn(IRETURN); - mv.visitLabel(l4); - mv.visitLineNumber(1304, l4); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_1); - mv.visitInsn(IADD); - mv.visitInsn(I2B); - mv.visitVarInsn(ISTORE, 1); - mv.visitLabel(l2); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_5); - mv.visitJumpInsn(IF_ICMPLT, l3); - Label l6 = new Label(); - mv.visitLabel(l6); - mv.visitLineNumber(1308, l6); - mv.visitInsn(ICONST_1); - mv.visitInsn(IRETURN); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); - mv.visitLocalVariable("i", "B", null, l1, l6, 1); - mv.visitMaxs(2, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); mv.visitEnd(); didInject = true; } @@ -677,51 +175,54 @@ public class ClassTransformer_GT_Utility { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); - mv.visitLineNumber(1312, l0); - mv.visitInsn(ICONST_1); - mv.visitVarInsn(ISTORE, 1); + mv.visitLineNumber(1293, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullGasHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitInsn(IRETURN); Label l1 = new Label(); mv.visitLabel(l1); - Label l2 = new Label(); - mv.visitJumpInsn(GOTO, l2); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLineNumber(1313, l3); - mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/EntityLivingBase", "getEquipmentInSlot", "(I)Lnet/minecraft/item/ItemStack;", false); - mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/HazmatUtils", "providesProtetion_Gas", "(Lnet/minecraft/item/ItemStack;)Z", false); - Label l4 = new Label(); - mv.visitJumpInsn(IFNE, l4); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLineNumber(1314, l5); - mv.visitInsn(ICONST_0); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("getTier")) { + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassNameFormatted+"."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getTier", "(J)B", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(23, l0); + mv.visitVarInsn(LLOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, aClassNameFormatted, "getTier", "(J)B", false); mv.visitInsn(IRETURN); - mv.visitLabel(l4); - mv.visitLineNumber(1312, l4); - mv.visitFrame(F_SAME, 0, null, 0, null); - mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_1); - mv.visitInsn(IADD); - mv.visitInsn(I2B); - mv.visitVarInsn(ISTORE, 1); - mv.visitLabel(l2); - mv.visitFrame(F_SAME, 0, null, 0, null); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("l", "J", null, l0, l1, 0); + mv.visitMaxs(2, 2); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("applyRadioactivity")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "applyRadioactivity", "(Lnet/minecraft/entity/EntityLivingBase;II)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1342, l0); + mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ILOAD, 1); - mv.visitInsn(ICONST_5); - mv.visitJumpInsn(IF_ICMPLT, l3); - Label l6 = new Label(); - mv.visitLabel(l6); - mv.visitLineNumber(1316, l6); - mv.visitInsn(ICONST_1); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "applyRadioactivity", "(Lnet/minecraft/entity/EntityLivingBase;II)Z", false); mv.visitInsn(IRETURN); - Label l7 = new Label(); - mv.visitLabel(l7); - mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l7, 0); - mv.visitLocalVariable("i", "B", null, l1, l6, 1); - mv.visitMaxs(2, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitLocalVariable("aLevel", "I", null, l0, l1, 1); + mv.visitLocalVariable("aAmountOfItems", "I", null, l0, l1, 2); + mv.visitMaxs(3, 3); mv.visitEnd(); didInject = true; } -- cgit From 492aa5becc6c49cc3afde8c855b5bbcdc5055e51 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 14 Apr 2020 00:05:16 +0100 Subject: + Added an Advanced Hazmat Suit. + Added a T3 circuit for recipe selections. $ Disabled TT Thaumic Repairer patch. $ Fixed a bug in EnumUtils not correctly handling missing entries. --- src/Java/gtPlusPlus/core/common/CommonProxy.java | 26 +--- .../gtPlusPlus/core/handler/EnumHelperHandler.java | 21 +++ .../core/item/chemistry/GenericChem.java | 78 ++++++++-- .../core/item/circuit/ItemAdvancedChip.java | 138 ++++++++++++++++++ .../item/wearable/hazmat/ItemArmorHazmatEx.java | 31 ++++ src/Java/gtPlusPlus/core/recipe/common/CI.java | 4 + src/Java/gtPlusPlus/core/util/data/EnumUtils.java | 7 +- .../core/util/reflect/ReflectionUtils.java | 24 ++++ .../gtPlusPlus/plugin/agrichem/BioRecipes.java | 10 +- src/Java/gtPlusPlus/preloader/asm/AsmConfig.java | 9 ++ .../ClassTransformer_TT_ThaumicRestorer.java | 158 ++++++++++++++++++++- .../Preloader_Transformer_Handler.java | 7 +- .../xmod/gregtech/api/enums/GregtechItemList.java | 7 + .../gtPlusPlus/xmod/ic2/CustomInternalName.java | 27 ++++ src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java | 3 + .../gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java | 87 ++++++++++++ src/resources/assets/ic2/lang/en_US.lang | 6 + .../assets/ic2/textures/armor/hazmatEx_1.png | Bin 0 -> 2669 bytes .../assets/ic2/textures/armor/hazmatEx_2.png | Bin 0 -> 967 bytes .../textures/items/itemArmorHazmatChestplateEx.png | Bin 0 -> 525 bytes .../ic2/textures/items/itemArmorHazmatHelmetEx.png | Bin 0 -> 464 bytes .../textures/items/itemArmorHazmatLeggingsEx.png | Bin 0 -> 418 bytes .../ic2/textures/items/itemArmorRubBootsEx.png | Bin 0 -> 459 bytes src/resources/assets/miscutils/lang/en_US.lang | 5 +- .../items/science/general/AdvancedCircuit.png | Bin 0 -> 515 bytes 25 files changed, 595 insertions(+), 53 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/EnumHelperHandler.java create mode 100644 src/Java/gtPlusPlus/core/item/circuit/ItemAdvancedChip.java create mode 100644 src/Java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java create mode 100644 src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java create mode 100644 src/resources/assets/ic2/textures/armor/hazmatEx_1.png create mode 100644 src/resources/assets/ic2/textures/armor/hazmatEx_2.png create mode 100644 src/resources/assets/ic2/textures/items/itemArmorHazmatChestplateEx.png create mode 100644 src/resources/assets/ic2/textures/items/itemArmorHazmatHelmetEx.png create mode 100644 src/resources/assets/ic2/textures/items/itemArmorHazmatLeggingsEx.png create mode 100644 src/resources/assets/ic2/textures/items/itemArmorRubBootsEx.png create mode 100644 src/resources/assets/miscutils/textures/items/science/general/AdvancedCircuit.png (limited to 'src/Java/gtPlusPlus/preloader/asm/transformers') diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 0aeff5ae16..4dad732e25 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -1,10 +1,6 @@ package gtPlusPlus.core.common; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLLoadCompleteEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; @@ -19,18 +15,8 @@ import gtPlusPlus.core.entity.monster.EntityGiantChickenBase; import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; import gtPlusPlus.core.fluids.FluidFactory; -import gtPlusPlus.core.handler.BookHandler; -import gtPlusPlus.core.handler.BurnableFuelHandler; -import gtPlusPlus.core.handler.COMPAT_HANDLER; -import gtPlusPlus.core.handler.COMPAT_IntermodStaging; -import gtPlusPlus.core.handler.GuiHandler; -import gtPlusPlus.core.handler.StopAnnoyingFuckingAchievements; -import gtPlusPlus.core.handler.events.BlockEventHandler; -import gtPlusPlus.core.handler.events.EnderDragonDeathHandler; -import gtPlusPlus.core.handler.events.EntityDeathHandler; -import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; -import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; -import gtPlusPlus.core.handler.events.ZombieBackupSpawnEventHandler; +import gtPlusPlus.core.handler.*; +import gtPlusPlus.core.handler.events.*; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.lib.CORE; @@ -50,7 +36,6 @@ import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; -import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; import net.minecraft.enchantment.Enchantment; @@ -89,10 +74,7 @@ public class CommonProxy { } AddToCreativeTab.initialiseTabs(); - - if (LoadedMods.Gregtech) { - HANDLER_GT.addNewOrePrefixes(); - } + EnumHelperHandler.init(); // Moved from Init after Debug Loading. // 29/01/18 - Alkalus diff --git a/src/Java/gtPlusPlus/core/handler/EnumHelperHandler.java b/src/Java/gtPlusPlus/core/handler/EnumHelperHandler.java new file mode 100644 index 0000000000..d164efa3d7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/EnumHelperHandler.java @@ -0,0 +1,21 @@ +package gtPlusPlus.core.handler; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import gtPlusPlus.xmod.ic2.CustomInternalName; + +public class EnumHelperHandler { + + public static void init() { + + if (LoadedMods.IndustrialCraft2) { + CustomInternalName.init(); + } + + if (LoadedMods.Gregtech) { + HANDLER_GT.addNewOrePrefixes(); + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java index 488151a773..fbbc1d24eb 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -1,18 +1,13 @@ package gtPlusPlus.core.item.chemistry; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.TextureSet; +import gregtech.api.enums.*; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; +import gtPlusPlus.core.item.circuit.ItemAdvancedChip; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.MISC_MATERIALS; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialGenerator; -import gtPlusPlus.core.material.MaterialStack; -import gtPlusPlus.core.material.NONMATERIAL; +import gtPlusPlus.core.material.*; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; @@ -25,10 +20,7 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.*; public class GenericChem extends ItemPackage { @@ -106,6 +98,7 @@ public class GenericChem extends ItemPackage { // Phenol Byproducts public Item PhenolicResins; //https://en.wikipedia.org/wiki/Phenol_formaldehyde_resin public static ItemGenericChemBase mGenericChemItem1; + public static Item mAdvancedCircuit; private ItemStack mCatalystCarrier; @@ -134,7 +127,9 @@ public class GenericChem extends ItemPackage { MaterialGenerator.generate(NYLON, false); MaterialGenerator.generate(TEFLON, false); - mGenericChemItem1 = new ItemGenericChemBase(); + mGenericChemItem1 = new ItemGenericChemBase(); + mAdvancedCircuit = new ItemAdvancedChip(); + GregtechItemList.Circuit_T3RecipeSelector.set(mAdvancedCircuit); registerItemStacks(); registerOreDict(); @@ -292,6 +287,7 @@ public class GenericChem extends ItemPackage { @Override public boolean generateRecipes() { + recipeAdvancedChip(); recipeCatalystRed(); recipeCatalystYellow(); recipeCatalystBlue(); @@ -1066,6 +1062,60 @@ public class GenericChem extends ItemPackage { return CI.getNumberedBioCircuit(16); } + private static void recipeAdvancedChip() { + GT_ModHandler.addShapelessCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 0L), 0, new Object[]{OrePrefixes.circuit.get(Materials.Advanced)}); + + long bits = 0; + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 1L, new Object[0]), bits, + new Object[]{"d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 2L, new Object[0]), bits, + new Object[]{" d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 3L, new Object[0]), bits, + new Object[]{" d", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 4L, new Object[0]), bits, + new Object[]{" ", " Pd", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 5L, new Object[0]), bits, + new Object[]{" ", " P ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 6L, new Object[0]), bits, + new Object[]{" ", " P ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 7L, new Object[0]), bits, + new Object[]{" ", " P ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 8L, new Object[0]), bits, + new Object[]{" ", "dP ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 9L, new Object[0]), bits, + new Object[]{"P d", " ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 10L, new Object[0]), bits, + new Object[]{"P ", " d", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 11L, new Object[0]), bits, + new Object[]{"P ", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 12L, new Object[0]), bits, + new Object[]{"P ", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 13L, new Object[0]), bits, + new Object[]{" P", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 14L, new Object[0]), bits, + new Object[]{" P", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 15L, new Object[0]), bits, + new Object[]{" P", " ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 16L, new Object[0]), bits, + new Object[]{" P", "d ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 17L, new Object[0]), bits, + new Object[]{" ", " ", "d P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 18L, new Object[0]), bits, + new Object[]{" ", "d ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 19L, new Object[0]), bits, + new Object[]{"d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 20L, new Object[0]), bits, + new Object[]{" d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 21L, new Object[0]), bits, + new Object[]{"d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 22L, new Object[0]), bits, + new Object[]{" d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 23L, new Object[0]), bits, + new Object[]{" d", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 24L, new Object[0]), bits, + new Object[]{" ", " d", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + } } diff --git a/src/Java/gtPlusPlus/core/item/circuit/ItemAdvancedChip.java b/src/Java/gtPlusPlus/core/item/circuit/ItemAdvancedChip.java new file mode 100644 index 0000000000..c375c32952 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/circuit/ItemAdvancedChip.java @@ -0,0 +1,138 @@ +package gtPlusPlus.core.item.circuit; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemAdvancedChip extends Item { + + protected IIcon base; + + public ItemAdvancedChip() { + this.setHasSubtypes(true); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("T3RecipeSelector"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return super.shouldRotateAroundWhenRendering(); + } + + @Override + public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + return super.getItemStackDisplayName(aStack); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + try { + aList.add("Configuration == "+aStack.getItemDamage()); + } + catch (Throwable t) { + t.printStackTrace(); + } + super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return EnumRarity.common; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + aList.add(ItemUtils.simpleMetaStack(aItem, 0, 1)); + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return stack.getItemDamage(); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public void registerIcons(final IIconRegister u) { + this.base = u.registerIcon(CORE.MODID + ":" + "science/general/AdvancedCircuit"); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + return this.base; + } + + @Override + public IIcon getIconFromDamage(int damage) { + return this.base; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return this.base; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return this.base; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(); + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java b/src/Java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java new file mode 100644 index 0000000000..1f8009e54a --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java @@ -0,0 +1,31 @@ +package gtPlusPlus.core.item.wearable.hazmat; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.ic2.CustomInternalName; +import ic2.core.IC2; +import ic2.core.init.InternalName; +import ic2.core.item.armor.ItemArmorHazmat; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; + +public class ItemArmorHazmatEx extends ItemArmorHazmat { + + public static void init() { + GregtechItemList.Armour_Hazmat_Advanced_Helmet.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatHelmetEx, 0))); + GregtechItemList.Armour_Hazmat_Advanced_Chest.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatChestEx, 1))); + GregtechItemList.Armour_Hazmat_Advanced_Legs.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatLegsEx, 2))); + GregtechItemList.Armour_Hazmat_Advanced_Boots.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatBootsEx, 3))); + } + + private ItemArmorHazmatEx(InternalName internalName, int type) { + super(internalName, type); + this.setMaxDamage(256); + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + int suffix = this.armorType == 2 ? 2 : 1; + return IC2.textureDomain + ":textures/armor/" + "hazmatEx_" + suffix + ".png"; + } + +} diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index d67a372572..93ede378a8 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -1235,6 +1235,10 @@ public class CI { return ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, i, 0); } + public static ItemStack getNumberedAdvancedCircuit(int i) { + return ItemUtils.simpleMetaStack(GenericChem.mAdvancedCircuit, i, 0); + } + public static ItemStack getTieredGTPPMachineCasing(int aTier, int aAmount) { GregtechItemList[] aHulls = new GregtechItemList[] { GregtechItemList.GTPP_Casing_ULV, diff --git a/src/Java/gtPlusPlus/core/util/data/EnumUtils.java b/src/Java/gtPlusPlus/core/util/data/EnumUtils.java index 9c96b61876..edcc071b54 100644 --- a/src/Java/gtPlusPlus/core/util/data/EnumUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/EnumUtils.java @@ -12,10 +12,13 @@ public class EnumUtils { **/ public static > T getValue(Class enumeration, String name) { Optional j = Enums.getIfPresent(enumeration, name); - T VALUE = j.get(); - if (j.get() == null) { + T VALUE; + if (j == null || !j.isPresent()) { VALUE = valueOfIgnoreCase(enumeration, name); } + else { + VALUE = j.get(); + } return VALUE; } diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 8b9b5cf94f..e0634dfb14 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -508,6 +508,30 @@ public class ReflectionUtils { Logger.REFLECTION("Invoke failed or did something wrong."); return false; } + + public static boolean invokeVoid(Object objectInstance, Method method, Object[] values){ + if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)){ + //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); + return false; + } + String methodName = method.getName(); + String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); + try { + Method mInvokingMethod = method; + if (mInvokingMethod != null){ + Logger.REFLECTION(methodName+" was not null."); + mInvokingMethod.invoke(objectInstance, values); + Logger.REFLECTION("Successfully invoked "+methodName+"."); + return true; + } + } + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); + } + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values){ if (objectInstance == null || methodName == null || parameters == null || values == null){ diff --git a/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java b/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java index f6a59e3900..490b94d71c 100644 --- a/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java +++ b/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java @@ -23,11 +23,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.MISC_MATERIALS; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.core.util.minecraft.OreDictUtils; -import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.plugin.agrichem.block.AgrichemFluids; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -1323,14 +1319,10 @@ public class BioRecipes { } private static void recipeBioChip() { - GT_ModHandler.addShapelessCraftingRecipe( GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(1L, 0L), 0, new Object[]{OrePrefixes.circuit.get(Materials.Primitive)}); long bits = 0; - - - addCraftingRecipe(GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(1L, 1L, new Object[0]), bits, new Object[]{"d ", " P ", " ", 'P', GregtechItemList.Circuit_BioRecipeSelector.getWildcard(1L, new Object[0])}); addCraftingRecipe(GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(1L, 2L, new Object[0]), bits, diff --git a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java index d0c59726de..a5981b15d9 100644 --- a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java +++ b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java @@ -30,6 +30,7 @@ public class AsmConfig { public static boolean enableTcAspectSafety; public static boolean enabledLwjglKeybindingFix; public static boolean enabledFixEntitySetHealth; + public static boolean enableThaumicTinkererRepairFix; public static boolean disableAllLogging; public static boolean debugMode; @@ -96,6 +97,14 @@ public class AsmConfig { enableOreDictPatch = prop.getBoolean(false); propOrderDebug.add(prop.getName()); + prop = config.get("debug", "enableThaumicTinkererRepairFix", false); + prop.comment = "Enable/Disable Patch for Thaumic Repairer"; + prop.setLanguageKey("gtpp.enableThaumicTinkererRepairFix").setRequiresMcRestart(true); + enableThaumicTinkererRepairFix = prop.getBoolean(false); + propOrderDebug.add(prop.getName()); + + + diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java index 1dc8c3bc38..05b8054ff8 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java @@ -2,19 +2,147 @@ package gtPlusPlus.preloader.asm.transformers; import static org.objectweb.asm.Opcodes.*; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + import org.apache.logging.log4j.Level; import org.objectweb.asm.*; +import cpw.mods.fml.common.Loader; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.Preloader_Logger; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; public class ClassTransformer_TT_ThaumicRestorer { private final boolean isValid; private final ClassReader reader; private final ClassWriter writer; + + private static boolean mInit = false; + + private static Class mTileRepairerClass; + private static Class mTTConfigHandler; + private static Class mTinkersConstructCompat; + private static Class mThaumicTinkerer; + private static Class mTCProxy; + + private static Method mIsTcTool; + private static Method mGetTcDamage; + private static Method mFixTcDamage; + private static Method mSparkle; + private static Method mDrawEssentia; + + private static Field mRepairTiconTools; + private static Field mTicksExisted; + private static Field mInventory; + private static Field mTookLastTick; + private static Field mDamageLastTick; + private static Field mProxyTC; + + private static boolean repairTConTools = false; // thaumic.tinkerer.common.block.tile.TileRepairer + private static final boolean isTConstructTool(ItemStack aStack) { + return ReflectionUtils.invoke(null, mIsTcTool, new Object[] {aStack}); + } + private static final int getDamage(ItemStack aStack) { + return (int) ReflectionUtils.invokeNonBool(null, mGetTcDamage, new Object[] {aStack}); + } + private static final boolean fixDamage(ItemStack aStack, int aAmount) { + return ReflectionUtils.invoke(null, mFixTcDamage, new Object[] {aStack, aAmount}); + } + private static final int drawEssentia(TileEntity aTile) { + return (int) ReflectionUtils.invokeNonBool(aTile, mDrawEssentia, new Object[] {}); + } + private static final void sparkle(float a, float b, float c, int d) { + ReflectionUtils.invokeVoid(ReflectionUtils.getFieldValue(mProxyTC), mSparkle, new Object[] {a, b, c, d}); + } + + public static void updateEntity(TileEntity aTile) { + if (!mInit) { + // Set the classes we need + mTileRepairerClass = ReflectionUtils.getClass("thaumic.tinkerer.common.block.tile.TileRepairer"); + mTTConfigHandler = ReflectionUtils.getClass("thaumic.tinkerer.common.core.handler.ConfigHandler"); + mTinkersConstructCompat = ReflectionUtils.getClass("thaumic.tinkerer.common.compat.TinkersConstructCompat"); + mThaumicTinkerer = ReflectionUtils.getClass("thaumic.tinkerer.common.ThaumicTinkerer"); + mTCProxy = ReflectionUtils.getClass("thaumcraft.common.CommonProxy"); + // Set the methods we need + mIsTcTool = ReflectionUtils.getMethod(mTinkersConstructCompat, "isTConstructTool", new Class[] {ItemStack.class}); + mGetTcDamage = ReflectionUtils.getMethod(mTinkersConstructCompat, "getDamage", new Class[] {ItemStack.class}); + mFixTcDamage = ReflectionUtils.getMethod(mTinkersConstructCompat, "fixDamage", new Class[] {ItemStack.class, int.class}); + mSparkle = ReflectionUtils.getMethod(mTCProxy, "sparkle", new Class[] {float.class, float.class, float.class, int.class}); + mDrawEssentia = ReflectionUtils.getMethod(mTileRepairerClass, "drawEssentia", new Class[] {}); + // Set the fields we need + mRepairTiconTools = ReflectionUtils.getField(mTTConfigHandler, "repairTConTools"); + mTicksExisted = ReflectionUtils.getField(mTileRepairerClass, "ticksExisted"); + mInventory = ReflectionUtils.getField(mTileRepairerClass, "inventorySlots"); + mTookLastTick = ReflectionUtils.getField(mTileRepairerClass, "tookLastTick"); + mDamageLastTick = ReflectionUtils.getField(mTileRepairerClass, "dmgLastTick"); + mProxyTC = ReflectionUtils.getField(mThaumicTinkerer, "tcProxy"); + repairTConTools = (boolean) ReflectionUtils.getFieldValue(mRepairTiconTools); + mInit = true; + } + if (mInit) { + if (mTileRepairerClass.isInstance(aTile)) { + int ticksExisted = (int) ReflectionUtils.getFieldValue(mTicksExisted, aTile); + ItemStack[] inventorySlots = (ItemStack[]) ReflectionUtils.getFieldValue(mInventory, aTile); + boolean tookLastTick = (boolean) ReflectionUtils.getFieldValue(mTookLastTick, aTile); + int dmgLastTick = (int) ReflectionUtils.getFieldValue(mDamageLastTick, aTile); + ticksExisted++; + ReflectionUtils.setField(aTile, mTicksExisted, ticksExisted); + boolean aDidRun = false; + if (ticksExisted % 10 == 0) { + if (Loader.isModLoaded("TConstruct") && repairTConTools && inventorySlots[0] != null && isTConstructTool(inventorySlots[0])) { + final int dmg = getDamage(inventorySlots[0]); + if (dmg > 0) { + final int essentia = drawEssentia(aTile); + fixDamage(inventorySlots[0], essentia); + aTile.markDirty(); + if (dmgLastTick != 0 && dmgLastTick != dmg) { + sparkle((float)(aTile.xCoord + 0.25 + Math.random() / 2.0), (float)(aTile.yCoord + 1 + Math.random() / 2.0), (float)(aTile.zCoord + 0.25 + Math.random() / 2.0), 0); + tookLastTick = true; + } + else { + tookLastTick = false; + } + } + else { + tookLastTick = false; + } + dmgLastTick = ((inventorySlots[0] == null) ? 0 : getDamage(inventorySlots[0])); + aDidRun = true; + } + if (inventorySlots[0] != null && inventorySlots[0].getItemDamage() > 0 && inventorySlots[0].getItem().isRepairable()) { + final int essentia2 = drawEssentia(aTile); + final int dmg2 = inventorySlots[0].getItemDamage(); + inventorySlots[0].setItemDamage(Math.max(0, dmg2 - essentia2)); + aTile.markDirty(); + if (dmgLastTick != 0 && dmgLastTick != dmg2) { + sparkle((float)(aTile.xCoord + 0.25 + Math.random() / 2.0), (float)(aTile.yCoord + 1 + Math.random() / 2.0), (float)(aTile.zCoord + 0.25 + Math.random() / 2.0), 0); + tookLastTick = true; + } + else { + tookLastTick = false; + } + } + else { + tookLastTick = false; + } + dmgLastTick = ((inventorySlots[0] == null) ? 0 : inventorySlots[0].getItemDamage()); + aDidRun = true; + } + if (aDidRun) { + ReflectionUtils.setField(aTile, mInventory, inventorySlots); + ReflectionUtils.setField(aTile, mTookLastTick, tookLastTick); + ReflectionUtils.setField(aTile, mDamageLastTick, dmgLastTick); + } + } + } + } + public ClassTransformer_TT_ThaumicRestorer(byte[] basicClass) { ClassReader aTempReader = null; ClassWriter aTempWriter = null; @@ -26,7 +154,8 @@ public class ClassTransformer_TT_ThaumicRestorer { obfuscated = aMethodStripper.isObfuscated; String aUpdateEntity = obfuscated ? "func_145845_h" : "updateEntity"; Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Patching: "+aUpdateEntity+", Are we patching obfuscated methods? "+obfuscated); - injectMethod(aUpdateEntity, aTempWriter, obfuscated); + //injectMethod(aUpdateEntity, aTempWriter, obfuscated); + injectMethodNew(aTempWriter, obfuscated); if (aTempReader != null && aTempWriter != null) { isValid = true; } @@ -49,6 +178,33 @@ public class ClassTransformer_TT_ThaumicRestorer { public ClassWriter getWriter() { return writer; } + + public boolean injectMethodNew(ClassWriter cw, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + String aUpdateEntity = obfuscated ? "func_145845_h" : "updateEntity"; + String aTileEntity = obfuscated ? "aor" : "net/minecraft/tileentity/TileEntity"; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Injecting " + aUpdateEntity + "."); + mv = cw.visitMethod(ACC_PUBLIC, aUpdateEntity, "()V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(60, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer", "updateEntity", "(L"+aTileEntity+";)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(61, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lthaumic/tinkerer/common/block/tile/TileRepairer;", null, l0, l2, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Method injection complete. "+(obfuscated ? "Obfuscated" : "Non-Obfuscated")); + return didInject; + } public boolean injectMethod(String aMethodName, ClassWriter cw, boolean obfuscated) { MethodVisitor mv; 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 398e69a2f9..cb9799fce7 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -272,10 +272,9 @@ public class Preloader_Transformer_Handler implements IClassTransformer { return new ClassTransformer_TC_ItemWispEssence(basicClass, obfuscated).getWriter().toByteArray(); } //Fix Thaumic Tinkerer Shit - //Patching ItemWispEssence to allow invalid item handling - if (transformedName.equals(THAUMICTINKERER_TILE_REPAIRER)) { - Preloader_Logger.INFO("Thaumic Tinkerer RepairItem Patch", "Transforming "+transformedName); - return new ClassTransformer_TT_ThaumicRestorer(basicClass).getWriter().toByteArray(); + if (transformedName.equals(THAUMICTINKERER_TILE_REPAIRER) && AsmConfig.enableThaumicTinkererRepairFix) { + //Preloader_Logger.INFO("Thaumic Tinkerer RepairItem Patch", "Transforming "+transformedName); + //return new ClassTransformer_TT_ThaumicRestorer(basicClass).getWriter().toByteArray(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 173b260d57..b7662ca25e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -19,6 +19,12 @@ public enum GregtechItemList implements GregtechItemContainer { /** * Items */ + + // Advanced Hazmat Suit + Armour_Hazmat_Advanced_Helmet, + Armour_Hazmat_Advanced_Chest, + Armour_Hazmat_Advanced_Legs, + Armour_Hazmat_Advanced_Boots, //Gregtech Machine Parts Electric_Motor_LuV, Electric_Motor_ZPM, Electric_Motor_UV, Electric_Motor_MAX, @@ -49,6 +55,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Recipe Circuit Circuit_BioRecipeSelector, + Circuit_T3RecipeSelector, //Circuits Old_Circuit_Primitive, Old_Circuit_Basic, Old_Circuit_Good, diff --git a/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java b/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java new file mode 100644 index 0000000000..18fb286d15 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java @@ -0,0 +1,27 @@ +package gtPlusPlus.xmod.ic2; + +import gtPlusPlus.core.util.data.EnumUtils; +import ic2.core.init.InternalName; +import net.minecraftforge.common.util.EnumHelper; + +public class CustomInternalName { + + public static InternalName aHazmatHelmetEx; + public static InternalName aHazmatChestEx; + public static InternalName aHazmatLegsEx; + public static InternalName aHazmatBootsEx; + + public static void init() { + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatHelmetEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatChestplateEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatLeggingsEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorRubBootsEx", new Class[] {}, new Object[] {}); + aHazmatHelmetEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatHelmetEx"); + aHazmatChestEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatChestplateEx"); + aHazmatLegsEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatLeggingsEx"); + aHazmatBootsEx = EnumUtils.getValue(InternalName.class, "itemArmorRubBootsEx"); + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java index 862ba38748..8c8b2ea7ad 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java +++ b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.ic2.item; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.item.wearable.hazmat.ItemArmorHazmatEx; import gtPlusPlus.core.lib.LoadedMods; import net.minecraft.item.ItemStack; @@ -52,6 +53,8 @@ public class IC2_Items { rotor_Material_2 = new ItemStack (new CustomKineticRotor(1)); rotor_Material_3 = new ItemStack (new CustomKineticRotor(2)); rotor_Material_4 = new ItemStack (new CustomKineticRotor(3)); + + ItemArmorHazmatEx.init(); } } diff --git a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java index 6c43e2b6e0..1f5f9abe1d 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java +++ b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.ic2.recipe; import static gtPlusPlus.core.recipe.RECIPES_Tools.*; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import gregtech.api.enums.*; @@ -12,10 +13,15 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.ic2.item.IC2_Items; +import ic2.core.Ic2Items; public class RECIPE_IC2 { @@ -84,6 +90,7 @@ public class RECIPE_IC2 { public static void initRecipes() { checkForEnderIO(); + addAdvancedHazmat(); if (!CORE.GTNH) { //Rotor Blade Recipes @@ -236,4 +243,84 @@ public class RECIPE_IC2 { } + + private static void addAdvancedHazmat() { + + ItemStack[] aBasicHazmatPieces = new ItemStack[] { + Ic2Items.hazmatHelmet.copy(), + Ic2Items.hazmatChestplate.copy(), + Ic2Items.hazmatLeggings.copy(), + Ic2Items.hazmatBoots.copy() + }; + + Material aRubber = MaterialUtils.generateMaterialFromGtENUM(Materials.Rubber); + ItemStack aYellowWool = ItemUtils.getSimpleStack(Blocks.wool, 4, 1); + ItemStack aBlackWool = ItemUtils.getSimpleStack(Blocks.wool, 15, 1); + ItemStack aCoilIC2 = Ic2Items.coil; + ItemStack aPlateCobalt = CI.getTieredComponentOfMaterial(Materials.Cobalt, OrePrefixes.plate, 1); + ItemStack aGearSmallSteel = CI.getTieredComponentOfMaterial(Materials.Steel, OrePrefixes.gearGtSmall, 1); + ItemStack aGearSmallAluminium = CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.gearGtSmall, 1); + ItemStack aGearPotin = ALLOY.TUMBAGA.getGear(1); + ItemStack aGearSiliconCarbide = ALLOY.SILICON_CARBIDE.getGear(1); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[0], + ItemUtils.getSimpleStack(aYellowWool,16), + ItemUtils.getSimpleStack(aPlateCobalt, 4), + ItemUtils.getSimpleStack(aCoilIC2, 8), + ItemUtils.getSimpleStack(aGearSmallAluminium, 4), + }, + aRubber.getFluid(144 * 4), + GregtechItemList.Armour_Hazmat_Advanced_Helmet.get(1), + 30 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[1], + ItemUtils.getSimpleStack(aYellowWool, 64), + ItemUtils.getSimpleStack(aCoilIC2, 32), + ItemUtils.getSimpleStack(aPlateCobalt, 16), + ItemUtils.getSimpleStack(aGearSiliconCarbide, 8), + }, + aRubber.getFluid(144 * 10), + GregtechItemList.Armour_Hazmat_Advanced_Chest.get(1), + 90 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[2], + ItemUtils.getSimpleStack(aYellowWool, 32), + ItemUtils.getSimpleStack(aCoilIC2, 16), + ItemUtils.getSimpleStack(aPlateCobalt, 8), + ItemUtils.getSimpleStack(aGearSiliconCarbide, 4), + }, + aRubber.getFluid(144 * 8), + GregtechItemList.Armour_Hazmat_Advanced_Legs.get(1), + 75 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[3], + ItemUtils.getSimpleStack(aBlackWool, 16), + ItemUtils.getSimpleStack(aCoilIC2, 6), + ItemUtils.getSimpleStack(aGearSmallSteel, 8), + ItemUtils.getSimpleStack(aGearPotin, 4), + }, + aRubber.getFluid(144 * 6), + GregtechItemList.Armour_Hazmat_Advanced_Boots.get(1), + 45 * 20, + MaterialUtils.getVoltageForTier(2)); + + } } diff --git a/src/resources/assets/ic2/lang/en_US.lang b/src/resources/assets/ic2/lang/en_US.lang index 3fb59885d4..9b44f2d14e 100644 --- a/src/resources/assets/ic2/lang/en_US.lang +++ b/src/resources/assets/ic2/lang/en_US.lang @@ -27,3 +27,9 @@ ic2.SulfuricLithium=Sulfuric Lithium Cell ic2.UraniumHexaFluoride=Uranium Hexafluoride Cell ic2.ThoriumTetraFluoride=Thorium Tetrafluoride Cell ic2.UraniumTetraFluoride=Uranium Tetrafluoride Cell + + +ic2.itemArmorHazmatHelmetEx=Advanced Hazmat Helmet +ic2.itemArmorHazmatChestplateEx=Advanced Hazmat Suit +ic2.itemArmorHazmatLeggingsEx=Advanced Hazmat Leggings +ic2.itemArmorRubBootsEx=Advanced Hazmat Boots \ No newline at end of file diff --git a/src/resources/assets/ic2/textures/armor/hazmatEx_1.png b/src/resources/assets/ic2/textures/armor/hazmatEx_1.png new file mode 100644 index 0000000000..2275007fbe Binary files /dev/null and b/src/resources/assets/ic2/textures/armor/hazmatEx_1.png differ diff --git a/src/resources/assets/ic2/textures/armor/hazmatEx_2.png b/src/resources/assets/ic2/textures/armor/hazmatEx_2.png new file mode 100644 index 0000000000..758adafdf2 Binary files /dev/null and b/src/resources/assets/ic2/textures/armor/hazmatEx_2.png differ diff --git a/src/resources/assets/ic2/textures/items/itemArmorHazmatChestplateEx.png b/src/resources/assets/ic2/textures/items/itemArmorHazmatChestplateEx.png new file mode 100644 index 0000000000..742d1d7035 Binary files /dev/null and b/src/resources/assets/ic2/textures/items/itemArmorHazmatChestplateEx.png differ diff --git a/src/resources/assets/ic2/textures/items/itemArmorHazmatHelmetEx.png b/src/resources/assets/ic2/textures/items/itemArmorHazmatHelmetEx.png new file mode 100644 index 0000000000..5340375595 Binary files /dev/null and b/src/resources/assets/ic2/textures/items/itemArmorHazmatHelmetEx.png differ diff --git a/src/resources/assets/ic2/textures/items/itemArmorHazmatLeggingsEx.png b/src/resources/assets/ic2/textures/items/itemArmorHazmatLeggingsEx.png new file mode 100644 index 0000000000..80cdca9b23 Binary files /dev/null and b/src/resources/assets/ic2/textures/items/itemArmorHazmatLeggingsEx.png differ diff --git a/src/resources/assets/ic2/textures/items/itemArmorRubBootsEx.png b/src/resources/assets/ic2/textures/items/itemArmorRubBootsEx.png new file mode 100644 index 0000000000..901a8fbc35 Binary files /dev/null and b/src/resources/assets/ic2/textures/items/itemArmorRubBootsEx.png differ diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index cb477971ac..df6fbaa5b3 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -3176,4 +3176,7 @@ item.FrothRedstoneflotation.name=Redstone Flotation Froth Cell item.FrothSpessartineflotation.name=Spessartine Flotation Froth Cell item.FrothGrossularflotation.name=Grossular Flotation Froth Cell item.FrothAlmandineflotation.name=Almandine Flotation Froth Cell -item.FrothPyropeflotation.name=Pyrope Flotation Froth Cell \ No newline at end of file +item.FrothPyropeflotation.name=Pyrope Flotation Froth Cell + +//Added 13/04/20 +item.T3RecipeSelector.name=Programmed Breakthrough Circuit \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/items/science/general/AdvancedCircuit.png b/src/resources/assets/miscutils/textures/items/science/general/AdvancedCircuit.png new file mode 100644 index 0000000000..8bcfa62ae4 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/science/general/AdvancedCircuit.png differ -- cgit