diff options
9 files changed, 880 insertions, 132 deletions
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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(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<GT_Recipe>(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<GT_ItemStack> sHazmatList = new GT_HashSet<GT_ItemStack>(); + + private static final HashMap<Item, Boolean> aIgnoreNBTMap = new HashMap<Item, Boolean>(); private static final HashMap<String, AutoMap<String>> mToolTips = new HashMap<String, AutoMap<String>>(); 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<ItemStack> aVanillaIC2Armour = new AutoMap<ItemStack>(); + 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<Field> aItemFields = new AutoMap<Field>(); + 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<ItemStack> aEMT = new AutoMap<ItemStack>(); + 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<Field> aItemFields = new AutoMap<Field>(); + Class aItemsGravisuite = ReflectionUtils.getClass("gravisuite.GraviSuite"); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "advNanoChestPlate")); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "graviChestPlate")); + AutoMap<ItemStack> aGravisuite = new AutoMap<ItemStack>(); + 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<Field> aItemFields = new AutoMap<Field>(); + 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<ItemStack> aASP = new AutoMap<ItemStack>(); + 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<ItemStack> aEquipment = new AutoMap<ItemStack>(); 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<String> 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<String> aTempTooltipData = mToolTips.get(aKey); if (aTempTooltipData == null) { Logger.INFO("No data mapped yet, creating."); aTempTooltipData = new AutoMap<String>(); + 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", "<init>", "(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", "<init>", "(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", "<init>", "(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", "<init>", "(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", "<init>", "(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", "<init>", "(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); + + } + +} |