From acf7193504fba4a7165d2ba5732cc9ce5f35ec55 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sat, 4 Apr 2020 16:57:56 +0100 Subject: + Added a new base bus type. + Added the Ball Housing bus. + Added the Catalyst Housing bus. + Added the Reinforced Engine Casing. + Made the Flotation Cell Regulator actually load. $ Fixed Tooltips on Milling Balls & Catalysts. $ Added improved item handling for Milling Balls. $ Added improved item handling for Catalysts. --- .../gtPlusPlus/core/util/reflect/ReflectionUtils.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Java/gtPlusPlus/core/util/reflect') diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index e45d27b926..59d20835ae 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -22,6 +22,7 @@ import com.google.common.reflect.ClassPath; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; public class ReflectionUtils { @@ -1035,5 +1036,19 @@ public class ReflectionUtils { return null; } + public static T createNewInstanceFromConstructor(Constructor aConstructor, Object[] aArgs) { + T aInstance; + try { + aInstance = (T) aConstructor.newInstance(aArgs); + if (aInstance != null) { + return aInstance; + } + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + } -- 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/core/util/reflect') 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 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/core/util/reflect') 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