aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/preloader/asm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/preloader/asm')
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java5
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_CC.java28
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java252
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_CC_GuiContainerManager.java121
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java317
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_InvTools.java17
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java513
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java192
-rw-r--r--src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java19
9 files changed, 1456 insertions, 8 deletions
diff --git a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java
index 3366f4aefe..ac8fd26415 100644
--- a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java
+++ b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java
@@ -39,6 +39,7 @@ public class ClassesToTransform {
public static final String GT_ITEM_MACHINES = "gregtech.common.blocks.GT_Item_Machines";
public static final String GT_METAGENERATED_TOOL = "gregtech.api.items.GT_MetaGenerated_Tool";
public static final String GT_BLOCK_MACHINES = "gregtech.common.blocks.GT_Block_Machines";
+ public static final String GT_MTE_HATCH_ENERGY = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy";
public static final String GT_MTE_HATCH_INPUTBUS = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus";
public static final String GT_MTE_HATCH_OUTPUTBUS = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus";
public static final String GT_METAPIPE_ITEM = "gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Item";
@@ -48,10 +49,12 @@ public class ClassesToTransform {
public static final String GTPP_MTE_HATCH_SUPER_INPUT_BUS = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Input";
public static final String GTPP_MTE_HATCH_SUPER_OUTPUT_BUS = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Output";
- public static final String NAME = "";
+ public static final String GTPP_MTE_HATCH_RTG = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG";
public static final String THAUMCRAFT_ITEM_WISP_ESSENCE = "thaumcraft.common.items.ItemWispEssence";
+ public static final String THAUMCRAFT_CRAFTING_MANAGER = "thaumcraft.common.lib.crafting.ThaumcraftCraftingManager";
+ public static final String THAUMCRAFT_TILE_ALCHEMY_FURNACE = "thaumcraft.common.tiles.TileAlchemyFurnace";
public static final String THAUMICTINKERER_TILE_REPAIRER = "thaumic.tinkerer.common.block.tile.TileRepairer";
public static final String IC2_ITEM_ARMOUR_HAZMAT = "ic2.core.item.armor.ItemArmorHazmat";
diff --git a/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_CC.java b/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_CC.java
new file mode 100644
index 0000000000..664ffe7b2d
--- /dev/null
+++ b/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_CC.java
@@ -0,0 +1,28 @@
+package gtPlusPlus.preloader.asm.helpers;
+
+import codechicken.nei.guihook.GuiContainerManager;
+import codechicken.nei.guihook.IContainerInputHandler;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+public class MethodHelper_CC {
+
+
+ public void mouseUp2(int mousex, int mousey, int button) {
+ MethodHelper_CC.mouseUp(mousex, mousey, button);
+ }
+
+ public static void mouseUp(int mousex, int mousey, int button) {
+ GuiContainerManager aManager = codechicken.nei.guihook.GuiContainerManager.getManager();
+ if (aManager != null) {
+ GuiContainer aWindow = aManager.window;
+ for (IContainerInputHandler inputhander : GuiContainerManager.inputHandlers) {
+ //Preloader_Logger.INFO("Found Handler: "+aWindow.getClass().getName() + " | "+inputhander.getClass().getName());
+ }
+ for (IContainerInputHandler inputhander : GuiContainerManager.inputHandlers) {
+ //Preloader_Logger.INFO("Trying to handle events for "+aWindow.getClass().getName() + " | "+inputhander.getClass().getName());
+ inputhander.onMouseUp(aWindow, mousex, mousey, button);
+ }
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java b/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java
new file mode 100644
index 0000000000..f1219241cf
--- /dev/null
+++ b/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java
@@ -0,0 +1,252 @@
+package gtPlusPlus.preloader.asm.helpers;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemPotion;
+import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import thaumcraft.api.ThaumcraftApi;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.items.wands.ItemWandCasting;
+import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager;
+
+public class MethodHelper_TC {
+
+ private static Class mThaumcraftCraftingManager;
+
+ public static AspectList generateTags(Item item, int meta) {
+ AspectList temp = generateTags(item, meta, new ArrayList());
+ return temp;
+ }
+
+ public static AspectList generateTags(final Item item, final int meta, final ArrayList<List> history) {
+ int tmeta = meta;
+ if (item == null) {
+ return null;
+ }
+ //Preloader_Logger.INFO("Generating aspect tags for "+item.getUnlocalizedName()+":"+meta);
+ try {
+ tmeta = ((new ItemStack(item, 1, meta).getItem().isDamageable() || !new ItemStack(item, 1, meta).getItem().getHasSubtypes()) ? 32767 : meta);
+ }
+ catch (Exception ex) {}
+ //Preloader_Logger.INFO("Set Meta to "+tmeta);
+ if (ThaumcraftApi.exists(item, tmeta)) {
+ return ThaumcraftCraftingManager.getObjectTags(new ItemStack(item, 1, tmeta));
+ }
+ if (history.contains(Arrays.asList(item, tmeta))) {
+ return null;
+ }
+ history.add(Arrays.asList(item, tmeta));
+ if (history.size() < 100) {
+ AspectList ret = generateTagsFromRecipes(item, (tmeta == 32767) ? 0 : meta, history);
+ ret = capAspects(ret, 64);
+ ThaumcraftApi.registerObjectTag(new ItemStack(item, 1, tmeta), ret);
+ return ret;
+ }
+ return null;
+ }
+
+ private static AspectList capAspects(final AspectList sourcetags, final int amount) {
+ if (sourcetags == null) {
+ return sourcetags;
+ }
+ final AspectList out = new AspectList();
+ for (final Aspect aspect : sourcetags.getAspects()) {
+ out.merge(aspect, Math.min(amount, sourcetags.getAmount(aspect)));
+ }
+ return out;
+ }
+
+ private static AspectList generateTagsFromRecipes(final Item item, final int meta, final ArrayList<List> history) {
+ AspectList ret = null;
+ ret = generateTagsFromCrucibleRecipes(item, meta, history);
+ if (ret != null) {
+ return ret;
+ }
+ ret = generateTagsFromArcaneRecipes(item, meta, history);
+ if (ret != null) {
+ return ret;
+ }
+ ret = generateTagsFromInfusionRecipes(item, meta, history);
+ if (ret != null) {
+ return ret;
+ }
+ ret = generateTagsFromCraftingRecipes(item, meta, history);
+ return ret;
+ }
+
+ private static boolean isClassSet() {
+ if (mThaumcraftCraftingManager == null) {
+ mThaumcraftCraftingManager = ReflectionUtils.getClass("thaumcraft.common.lib.crafting.ThaumcraftCraftingManager");
+ }
+ return true;
+ }
+
+ private static Method mGetTagsFromCraftingRecipes;
+ private static Method mGetTagsFromInfusionRecipes;
+ private static Method mGetTagsFromArcaneRecipes;
+ private static Method mGetTagsFromCrucibleRecipes;
+
+ private static AspectList generateTagsFromCraftingRecipes(Item item, int meta, ArrayList<List> history) {
+ isClassSet();
+ if (mGetTagsFromCraftingRecipes == null) {
+ mGetTagsFromCraftingRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromCraftingRecipes", new Class[] {Item.class, int.class, ArrayList.class});
+ }
+ return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromCraftingRecipes, new Object[] {item, meta, history});
+ }
+
+ private static AspectList generateTagsFromInfusionRecipes(Item item, int meta, ArrayList<List> history) {
+ isClassSet();
+ if (mGetTagsFromInfusionRecipes == null) {
+ mGetTagsFromInfusionRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromInfusionRecipes", new Class[] {Item.class, int.class, ArrayList.class});
+ }
+ return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromInfusionRecipes, new Object[] {item, meta, history});
+ }
+
+ private static AspectList generateTagsFromArcaneRecipes(Item item, int meta, ArrayList<List> history) {
+ isClassSet();
+ if (mGetTagsFromArcaneRecipes == null) {
+ mGetTagsFromArcaneRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromArcaneRecipes", new Class[] {Item.class, int.class, ArrayList.class});
+ }
+ return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromArcaneRecipes, new Object[] {item, meta, history});
+ }
+
+ private static AspectList generateTagsFromCrucibleRecipes(Item item, int meta, ArrayList<List> history) {
+ isClassSet();
+ if (mGetTagsFromCrucibleRecipes == null) {
+ mGetTagsFromCrucibleRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromCrucibleRecipes", new Class[] {Item.class, int.class, ArrayList.class});
+ }
+ return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromCrucibleRecipes, new Object[] {item, meta, history});
+ }
+
+
+
+ /*
+ * Let's improve the TC lookup for aspects, cause the default implementation is shit.
+ */
+
+
+ public static AspectList getObjectTags(ItemStack itemstack) {
+ Item item;
+ int meta;
+ try {
+ item = itemstack.getItem();
+ meta = itemstack.getItemDamage();
+ } catch (Exception var8) {
+ return null;
+ }
+
+ AspectList tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, Integer.valueOf(meta)}));
+ if(tmp == null) {
+ for(List l : ThaumcraftApi.objectTags.keySet()) {
+ if((Item)l.get(0) == item && l.get(1) instanceof int[]) {
+ int[] range = (int[])((int[])l.get(1));
+ Arrays.sort(range);
+ if(Arrays.binarySearch(range, meta) >= 0) {
+ tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, range}));
+ return tmp;
+ }
+ }
+ }
+
+ tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, Integer.valueOf(32767)}));
+ if(tmp == null && tmp == null) {
+ if(meta == 32767 && tmp == null) {
+ int index = 0;
+
+ while(true) {
+ tmp = (AspectList)ThaumcraftApi.objectTags.get(Arrays.asList(new Object[]{item, Integer.valueOf(index)}));
+ ++index;
+ if(index >= 16 || tmp != null) {
+ break;
+ }
+ }
+ }
+
+ if(tmp == null) {
+ tmp = generateTags(item, meta);
+ }
+ }
+ }
+
+ if(itemstack.getItem() instanceof ItemWandCasting) {
+ ItemWandCasting wand = (ItemWandCasting)itemstack.getItem();
+ if(tmp == null) {
+ tmp = new AspectList();
+ }
+
+ tmp.merge(Aspect.MAGIC, (wand.getRod(itemstack).getCraftCost() + wand.getCap(itemstack).getCraftCost()) / 2);
+ tmp.merge(Aspect.TOOL, (wand.getRod(itemstack).getCraftCost() + wand.getCap(itemstack).getCraftCost()) / 3);
+ }
+
+ if(item != null && item == Items.potionitem) {
+ if(tmp == null) {
+ tmp = new AspectList();
+ }
+
+ tmp.merge(Aspect.WATER, 1);
+ ItemPotion ip = (ItemPotion)item;
+ List<PotionEffect> effects = ip.getEffects(itemstack.getItemDamage());
+ if(effects != null) {
+ if(ItemPotion.isSplash(itemstack.getItemDamage())) {
+ tmp.merge(Aspect.ENTROPY, 2);
+ }
+
+ for(PotionEffect var6 : effects) {
+ tmp.merge(Aspect.MAGIC, (var6.getAmplifier() + 1) * 2);
+ if(var6.getPotionID() == Potion.blindness.id) {
+ tmp.merge(Aspect.DARKNESS, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.confusion.id) {
+ tmp.merge(Aspect.ELDRITCH, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.damageBoost.id) {
+ tmp.merge(Aspect.WEAPON, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.digSlowdown.id) {
+ tmp.merge(Aspect.TRAP, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.digSpeed.id) {
+ tmp.merge(Aspect.TOOL, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.fireResistance.id) {
+ tmp.merge(Aspect.ARMOR, var6.getAmplifier() + 1);
+ tmp.merge(Aspect.FIRE, (var6.getAmplifier() + 1) * 2);
+ } else if(var6.getPotionID() == Potion.harm.id) {
+ tmp.merge(Aspect.DEATH, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.heal.id) {
+ tmp.merge(Aspect.HEAL, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.hunger.id) {
+ tmp.merge(Aspect.DEATH, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.invisibility.id) {
+ tmp.merge(Aspect.SENSES, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.jump.id) {
+ tmp.merge(Aspect.FLIGHT, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.moveSlowdown.id) {
+ tmp.merge(Aspect.TRAP, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.moveSpeed.id) {
+ tmp.merge(Aspect.MOTION, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.nightVision.id) {
+ tmp.merge(Aspect.SENSES, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.poison.id) {
+ tmp.merge(Aspect.POISON, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.regeneration.id) {
+ tmp.merge(Aspect.HEAL, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.resistance.id) {
+ tmp.merge(Aspect.ARMOR, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.waterBreathing.id) {
+ tmp.merge(Aspect.AIR, (var6.getAmplifier() + 1) * 3);
+ } else if(var6.getPotionID() == Potion.weakness.id) {
+ tmp.merge(Aspect.DEATH, (var6.getAmplifier() + 1) * 3);
+ }
+ }
+ }
+ }
+
+ return capAspects(tmp, 64);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_CC_GuiContainerManager.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_CC_GuiContainerManager.java
new file mode 100644
index 0000000000..8791d401c8
--- /dev/null
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_CC_GuiContainerManager.java
@@ -0,0 +1,121 @@
+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_CC_GuiContainerManager {
+
+ private final boolean isValid;
+ private final ClassReader reader;
+ private final ClassWriter writer;
+
+ public ClassTransformer_CC_GuiContainerManager(byte[] basicClass) {
+
+ ClassReader aTempReader = null;
+ ClassWriter aTempWriter = null;
+
+ aTempReader = new ClassReader(basicClass);
+ aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES);
+ localClassVisitor aTempMethodRemover = new localClassVisitor(aTempWriter);
+ aTempReader.accept(aTempMethodRemover, 0);
+
+ if (aTempReader != null && aTempWriter != null) {
+ isValid = true;
+ } else {
+ isValid = false;
+ }
+
+ Preloader_Logger.LOG("CodeChicken GuiContainerManager Patch", Level.INFO, "Valid patch? " + isValid + ".");
+ reader = aTempReader;
+ writer = aTempWriter;
+
+ if (reader != null && writer != null) {
+ Preloader_Logger.LOG("CodeChicken GuiContainerManager Patch", Level.INFO, "Attempting Method Injection.");
+ injectMethod("mouseUp");
+ }
+
+ }
+
+ public boolean isValidTransformer() {
+ return isValid;
+ }
+
+ public ClassReader getReader() {
+ return reader;
+ }
+
+ public ClassWriter getWriter() {
+ return writer;
+ }
+
+ public boolean injectMethod(String aMethodName) {
+ MethodVisitor mv;
+ boolean didInject = false;
+ String aClassName = "codechicken/nei/guihook/GuiContainerManager";
+ ClassWriter cw = getWriter();
+ if (aMethodName.equals("mouseUp")) {
+ Preloader_Logger.LOG("CodeChicken GuiContainerManager Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassName+".");
+ mv = cw.visitMethod(ACC_PUBLIC, "mouseUp", "(III)V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(12, l0);
+ mv.visitVarInsn(ILOAD, 1);
+ mv.visitVarInsn(ILOAD, 2);
+ mv.visitVarInsn(ILOAD, 3);
+ mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/helpers/MethodHelper_CC", "mouseUp", "(III)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(13, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "L+aClassName+;", null, l0, l2, 0);
+ mv.visitLocalVariable("mousex", "I", null, l0, l2, 1);
+ mv.visitLocalVariable("mousey", "I", null, l0, l2, 2);
+ mv.visitLocalVariable("button", "I", null, l0, l2, 3);
+ mv.visitMaxs(3, 4);
+ mv.visitEnd();
+ didInject = true;
+ }
+
+ Preloader_Logger.LOG("CodeChicken GuiContainerManager Patch", Level.INFO, "Method injection complete.");
+ return didInject;
+ }
+
+ public final class localClassVisitor extends ClassVisitor {
+
+ boolean obfuscated = false;
+
+ public localClassVisitor(ClassVisitor cv) {
+ super(ASM5, cv);
+ }
+
+ public boolean getObfuscatedRemoval() {
+ return obfuscated;
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ MethodVisitor methodVisitor;
+
+ if (name.equals("mouseUp")) {
+ methodVisitor = null;
+ }
+ else {
+ methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
+ }
+
+ if (methodVisitor == null) {
+ Preloader_Logger.LOG("CodeChicken GuiContainerManager Patch", Level.INFO, "Found method " + name + ", removing.");
+ Preloader_Logger.LOG("CodeChicken GuiContainerManager Patch", Level.INFO, "Descriptor: "+desc);
+ }
+ return methodVisitor;
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java
new file mode 100644
index 0000000000..83560eb6c3
--- /dev/null
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_EnergyHatchPatch.java
@@ -0,0 +1,317 @@
+package gtPlusPlus.preloader.asm.transformers;
+
+import static org.objectweb.asm.Opcodes.*;
+
+import org.apache.logging.log4j.Level;
+import org.objectweb.asm.*;
+
+import cpw.mods.fml.relauncher.FMLRelaunchLog;
+import gtPlusPlus.preloader.asm.ClassesToTransform;
+
+public class ClassTransformer_GT_EnergyHatchPatch {
+
+ private static final String aRtgInputFormatted = ClassesToTransform.GTPP_MTE_HATCH_RTG.replace(".", "/");
+ private static final String aEnergyFormatted = ClassesToTransform.GT_MTE_HATCH_ENERGY.replace(".", "/");
+
+ private final boolean isValid;
+ private final ClassReader reader;
+ private final ClassWriter writer;
+
+
+ public ClassTransformer_GT_EnergyHatchPatch(byte[] basicClass, String aClassName) {
+ ClassReader aTempReader = null;
+ ClassWriter aTempWriter = null;
+
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Attempting to add slots capabilities to GT Energy Hatches.");
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Patching "+aClassName+".");
+
+ aTempReader = new ClassReader(basicClass);
+ aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES);
+ aTempReader.accept(new localClassVisitor(aTempWriter, aClassName), 0);
+
+ if (aTempReader != null && aTempWriter != null) {
+ isValid = true;
+ }
+ else {
+ isValid = false;
+ }
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Valid patch? "+isValid+".");
+ reader = aTempReader;
+ writer = aTempWriter;
+
+
+ if (reader != null && writer != null) {
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Attempting Method Injection.");
+ injectMethod(aClassName);
+ }
+
+ }
+
+ public boolean isValidTransformer() {
+ return isValid;
+ }
+
+ public ClassReader getReader() {
+ return reader;
+ }
+
+ public ClassWriter getWriter() {
+ return writer;
+ }
+
+
+ public boolean injectMethod(String aClassName) {
+
+ boolean didInject = false;
+ MethodVisitor mv;
+ ClassWriter cw = getWriter();
+ int aConID = 1;
+
+ //GT_MetaTileEntity_Hatch_Energy
+ //Constructor
+ if (aClassName.equals(ClassesToTransform.GT_MTE_HATCH_ENERGY)){
+
+
+ //Constructor 1
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;)V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(26, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ILOAD, 1);
+ mv.visitVarInsn(ALOAD, 2);
+ mv.visitVarInsn(ALOAD, 3);
+ mv.visitVarInsn(ILOAD, 4);
+ mv.visitVarInsn(ILOAD, 5);
+ mv.visitVarInsn(ALOAD, 6);
+ mv.visitInsn(ICONST_0);
+ mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture");
+ mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(27, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy;", null, l0, l2, 0);
+ mv.visitLocalVariable("aID", "I", null, l0, l2, 1);
+ mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 2);
+ mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l2, 3);
+ mv.visitLocalVariable("aTier", "I", null, l0, l2, 4);
+ mv.visitLocalVariable("aSlots", "I", null, l0, l2, 5);
+ mv.visitLocalVariable("aDesc", "[Ljava/lang/String;", null, l0, l2, 6);
+ mv.visitMaxs(8, 7);
+ mv.visitEnd();
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++));
+ }
+
+ //Constructor 2
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(30, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitVarInsn(ILOAD, 2);
+ mv.visitVarInsn(ILOAD, 3);
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitVarInsn(ALOAD, 5);
+ mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(31, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy;", null, l0, l2, 0);
+ mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1);
+ mv.visitLocalVariable("aTier", "I", null, l0, l2, 2);
+ mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3);
+ mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l2, 4);
+ mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5);
+ mv.visitMaxs(6, 6);
+ mv.visitEnd();
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++));
+ }
+
+ //Third constructor with String[] for GT 5.09
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(34, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitVarInsn(ILOAD, 2);
+ mv.visitVarInsn(ILOAD, 3);
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitVarInsn(ALOAD, 5);
+ mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(35, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy;", null, l0, l2, 0);
+ mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1);
+ mv.visitLocalVariable("aTier", "I", null, l0, l2, 2);
+ mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3);
+ mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l2, 4);
+ mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5);
+ mv.visitMaxs(6, 6);
+ mv.visitEnd();
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++));
+ }
+ didInject = true;
+ }
+
+ //GT_MetaTileEntity_Hatch_Energy_RTG
+ //Constructor
+ if (aClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_RTG)){
+
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(38, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ILOAD, 1);
+ mv.visitVarInsn(ALOAD, 2);
+ mv.visitVarInsn(ALOAD, 3);
+ mv.visitVarInsn(ILOAD, 4);
+ mv.visitVarInsn(ILOAD, 5);
+ mv.visitInsn(ICONST_2);
+ mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
+ mv.visitInsn(DUP);
+ mv.visitInsn(ICONST_0);
+ mv.visitLdcInsn("Energy Injector for Multiblocks");
+ mv.visitInsn(AASTORE);
+ mv.visitInsn(DUP);
+ mv.visitInsn(ICONST_1);
+ mv.visitLdcInsn("Accepts RTG pellets for Fuel");
+ mv.visitInsn(AASTORE);
+ mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy", "<init>", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(39, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG;", null, l0, l2, 0);
+ mv.visitLocalVariable("aID", "I", null, l0, l2, 1);
+ mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 2);
+ mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l2, 3);
+ mv.visitLocalVariable("aTier", "I", null, l0, l2, 4);
+ mv.visitLocalVariable("aSlots", "I", null, l0, l2, 5);
+ mv.visitMaxs(10, 6);
+ mv.visitEnd();
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++));
+ }
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(42, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitVarInsn(ILOAD, 2);
+ mv.visitVarInsn(ILOAD, 3);
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitVarInsn(ALOAD, 5);
+ mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(43, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG;", null, l0, l2, 0);
+ mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1);
+ mv.visitLocalVariable("aTier", "I", null, l0, l2, 2);
+ mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3);
+ mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l2, 4);
+ mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5);
+ mv.visitMaxs(6, 6);
+ mv.visitEnd();
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++));
+ }
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitLineNumber(46, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitVarInsn(ILOAD, 2);
+ mv.visitVarInsn(ILOAD, 3);
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitVarInsn(ALOAD, 5);
+ mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy", "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLineNumber(47, l1);
+ mv.visitInsn(RETURN);
+ Label l2 = new Label();
+ mv.visitLabel(l2);
+ mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG;", null, l0, l2, 0);
+ mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1);
+ mv.visitLocalVariable("aTier", "I", null, l0, l2, 2);
+ mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3);
+ mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l2, 4);
+ mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5);
+ mv.visitMaxs(6, 6);
+ mv.visitEnd();
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Injection new constructor "+(aConID++));
+ }
+
+
+ didInject = true;
+ }
+
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Method injection complete. Successful? "+didInject);
+ return didInject;
+
+ }
+
+ public final class localClassVisitor extends ClassVisitor {
+
+ private final String mClassName;
+
+ public localClassVisitor(ClassVisitor cv, String aClassName) {
+ super(ASM5, cv);
+ mClassName = aClassName;
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ MethodVisitor methodVisitor = null;
+ if ((mClassName.equals(ClassesToTransform.GTPP_MTE_HATCH_RTG)) && access == ACC_PUBLIC && name.equals("<init>") && (desc.equals("(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V") || desc.equals("(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V"))) {
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Found Constructor, "+"'"+access+"', "+"'"+name+"', "+"'"+desc+"', "+"'"+signature+"'");
+ methodVisitor = null;
+ }
+ else {
+ methodVisitor = super.visitMethod(access, name, desc, signature, exceptions);
+ }
+ if (methodVisitor == null) {
+ if (mClassName.equals(ClassesToTransform.GT_MTE_HATCH_ENERGY)){
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Removed method from "+mClassName);
+ }
+ else {
+ FMLRelaunchLog.log("[GT++ ASM] Gregtech Energy Hatch Patch", Level.INFO, "Removed Constructor with descriptor '"+desc+"' from "+mClassName);
+ }
+ }
+ return methodVisitor;
+ }
+ }
+
+
+}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_InvTools.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_InvTools.java
index 30ee37d7b3..75896c1c0f 100644
--- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_InvTools.java
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_InvTools.java
@@ -34,16 +34,19 @@ public class ClassTransformer_Railcraft_InvTools {
if (stack == null) {
return GT_Values.NI;
} else {
- if (stack.stackSize <= 1) {
+ if (stack.stackSize == 0) {
+ return GT_Values.NI;
+ }
+ else if (stack.stackSize == 1) {
ItemStack container = stack.getItem().getContainerItem(stack);
if (container != null) {
return container;
} else {
return GT_Values.NI;
}
- } else {
- ItemUtils.depleteStack(stack);
- return stack;
+ }
+ else {
+ return ItemUtils.depleteStack(stack);
}
}
}
@@ -85,11 +88,11 @@ public class ClassTransformer_Railcraft_InvTools {
}
if (obfuscated && devEnv) {
-
+
}
else {
-
-
+
+
}
diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java
new file mode 100644
index 0000000000..abdfb7d25a
--- /dev/null
+++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_AlchemicalFurnace.java
@@ -0,0 +1,513 @@
+package gtPlusPlus.preloader.asm.transformers;
+
+import static org.objectweb.asm.Opcodes.*;
+
+import org.apache.logging.log4j.Level;
+import org.objectweb.asm.*;
+
+import cpw.mods.fml.relauncher.FMLRelaunchLog;
+import gtPlusPlus.preloader.Preloader_Logger;
+
+public class ClassTransformer_TC_AlchemicalFurnace {
+
+ private final boolean isValid;
+ private final ClassReader reader;
+ private final ClassWriter writer;
+
+ public ClassTransformer_TC_AlchemicalFurnace(byte[] basicClass) {
+
+ ClassReader aTempReader = null;
+ ClassWriter aTempWriter = null;
+
+ aTempReader = new ClassReader(basicClass);
+ aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES);
+ localClassVisitor aTempMethodRemover = new localClassVisitor(aTempWriter);
+ aTempReader.accept(aTempMethodRemover, 0);
+ boolean wasMethodObfuscated = aTempMethodRemover.getObfuscatedRemoval();
+
+ if (aTempReader != null && aTempWriter != null) {
+ isValid = true;
+ } else {
+ isValid = false;
+ }
+
+ if (isValid) {
+ Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Attempting Field Injection.");
+ boolean fields = addField(aTempWriter);
+ Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Success? "+fields);
+ Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Attempting Method Injection.");
+ boolean methods = injectMethod(wasMethodObfuscated, aTempWriter);
+ Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Success? "+methods);
+ }
+
+ Preloader_Logger.LOG("TC Alchemy Furnace Patch", Level.INFO, "Valid patch? " + isValid + ".");
+ reader = aTempReader;