diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Utils.java | 42 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java | 60 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java | 648 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java | 31 |
4 files changed, 470 insertions, 311 deletions
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 624ed35b60..e2220f74f8 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -40,6 +40,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; @@ -544,6 +545,47 @@ public class Utils { } return null; } + + public static String sanitizeString(final String input, final char[] aDontRemove) { + + String output; + AutoMap<String> aToRemoveMap = new AutoMap<String>(); + + aToRemoveMap.put(" "); + aToRemoveMap.put("-"); + aToRemoveMap.put("_"); + aToRemoveMap.put("~"); + aToRemoveMap.put("?"); + aToRemoveMap.put("!"); + aToRemoveMap.put("@"); + aToRemoveMap.put("#"); + aToRemoveMap.put("$"); + aToRemoveMap.put("%"); + aToRemoveMap.put("^"); + aToRemoveMap.put("&"); + aToRemoveMap.put("*"); + aToRemoveMap.put("("); + aToRemoveMap.put(")"); + aToRemoveMap.put("{"); + aToRemoveMap.put("}"); + aToRemoveMap.put("["); + aToRemoveMap.put("]"); + aToRemoveMap.put(" "); + + for (String s : aToRemoveMap) { + for (char e : aDontRemove) { + if (s.charAt(0) == e) { + aToRemoveMap.remove("s"); + } + } + } + output = input; + for (String A : aToRemoveMap) { + output = output.replace(A, ""); + } + return output; + + } public static String sanitizeString(final String input) { String temp; diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java new file mode 100644 index 0000000000..a1c2bf6104 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java @@ -0,0 +1,60 @@ +package gtPlusPlus.core.util.minecraft; + +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; + +public class FoodUtils { + + public static final Class IEdibleClass; + + static { + IEdibleClass = ReflectionUtils.getClassByName("squeek.applecore.api.food.IEdible"); + } + + public static boolean isFood(ItemStack food) { + + if (food == null) { + return false; + } + + Item item = food.getItem(); + + if(item == null) { + return false; + } + + EnumAction action = item.getItemUseAction(food); + + if(item instanceof ItemBlock || action == EnumAction.eat || action == EnumAction.drink) { + if(getUnmodifiedFoodValues(food) > 0) { + return true; + } + } + + return false; + } + + private static int getUnmodifiedFoodValues(ItemStack stack) { + + if (stack == null) { + return 0; + } + + Item item = stack.getItem(); + + if(item == null) { + return 0; + } + + if(IEdibleClass.isInstance(item) || item instanceof ItemFood || item == Items.cake) { + return 1; + } + + return 0; + } +} diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index c7c38eab7d..1a3219bb90 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -6,6 +6,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; import net.minecraft.block.Block; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; @@ -16,7 +17,8 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; - +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.GregtechException; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -39,164 +41,173 @@ import net.minecraftforge.oredict.OreDictionary; public class ItemUtils { - public static ItemStack getSimpleStack(final Item x){ + public static ItemStack getSimpleStack(final Item x) { return getSimpleStack(x, 1); } - public static ItemStack getSimpleStack(final Block x){ + + public static ItemStack getSimpleStack(final Block x) { return simpleMetaStack(Item.getItemFromBlock(x), 0, 1); } - public static ItemStack getSimpleStack(final Block x, int meta){ + + public static ItemStack getSimpleStack(final Block x, int meta) { return simpleMetaStack(Item.getItemFromBlock(x), meta, 1); } - public static ItemStack getSimpleStack(final Item x, final int i){ + + public static ItemStack getSimpleStack(final Item x, final int i) { try { final ItemStack r = new ItemStack(x, i); return r.copy(); - } catch(final Throwable e){ + } catch (final Throwable e) { return null; } } - public static ItemStack getSimpleStack(final ItemStack x, final int i){ + + public static ItemStack getSimpleStack(final ItemStack x, final int i) { try { final ItemStack r = x.copy(); r.stackSize = i; return r; - } catch(final Throwable e){ + } catch (final Throwable e) { return null; } } public static final int WILDCARD_VALUE = Short.MAX_VALUE; - public static ItemStack getWildcardStack(final Item x){ + + public static ItemStack getWildcardStack(final Item x) { final ItemStack y = new ItemStack(x, 1, WILDCARD_VALUE); return y; } + public static ItemStack getIC2Cell(final String S) { + final ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + S, 1); - public static ItemStack getIC2Cell(final String S){ - final ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+S, 1); - - if (moreTemp == null){ + if (moreTemp == null) { final int cellID = 0; - final ItemStack temp =GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); + final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); return temp != null ? temp : null; } return moreTemp; } - public static ItemStack getIC2Cell(final int meta){ + public static ItemStack getIC2Cell(final int meta) { final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta); return temp != null ? temp : null; } - public static ItemStack getEmptyCell(){ + public static ItemStack getEmptyCell() { return getEmptyCell(1); } - public static ItemStack getEmptyCell(int i){ + public static ItemStack getEmptyCell(int i) { if (ItemList.Cell_Empty.hasBeenSet()) { return ItemList.Cell_Empty.get(i); - } + } final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", i, 0); return temp != null ? temp : null; } - public static void getItemForOreDict(final String FQRN, final String oreDictName, final String itemName, final int meta){ + public static void getItemForOreDict(final String FQRN, final String oreDictName, final String itemName, + final int meta) { try { Item em = null; final Item em1 = getItem(FQRN); - //Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ + // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null) { em = em1; } - if (em != null){ + if (em != null) { - final ItemStack metaStack = new ItemStack(em,1,meta); + final ItemStack metaStack = new ItemStack(em, 1, meta); GT_OreDictUnificator.registerOre(oreDictName, metaStack); - /*ItemStack itemStackWithMeta = new ItemStack(em,1,meta); - GT_OreDictUnificator.registerOre(oreDictName, new ItemStack(itemStackWithMeta.getItem()));*/ + /* + * ItemStack itemStackWithMeta = new ItemStack(em,1,meta); + * GT_OreDictUnificator.registerOre(oreDictName, new + * ItemStack(itemStackWithMeta.getItem())); + */ } } catch (final NullPointerException e) { - Logger.ERROR(itemName+" not found. [NULL]"); + Logger.ERROR(itemName + " not found. [NULL]"); } } - public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName){ + public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName) { try { GT_OreDictUnificator.registerOre(oreDictName, stack); } catch (final NullPointerException e) { - Logger.ERROR(stack.getDisplayName()+" not registered. [NULL]"); + Logger.ERROR(stack.getDisplayName() + " not registered. [NULL]"); } } - public static ItemStack getItemStackWithMeta(final boolean MOD, final String FQRN, final String itemName, final int meta, final int itemstackSize){ - if (MOD){ + public static ItemStack getItemStackWithMeta(final boolean MOD, final String FQRN, final String itemName, + final int meta, final int itemstackSize) { + if (MOD) { try { Item em = null; final Item em1 = getItem(FQRN); - //Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - if (null == em){ + // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null) { + if (null == em) { em = em1; } - if (em != null){ - final ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + if (em != null) { + final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); return metaStack; } } return null; } catch (final NullPointerException e) { - Logger.ERROR(itemName+" not found. [NULL]"); + Logger.ERROR(itemName + " not found. [NULL]"); return null; } } return null; } - public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize){ + public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { try { Item em = null; final Item em1 = getItem(FQRN); - //Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - if (null == em){ + // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null) { + if (null == em) { em = em1; } - if (em != null){ - final ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + if (em != null) { + final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); return metaStack; } } return null; } catch (final NullPointerException e) { - Logger.ERROR(FQRN+" not found. [NULL]"); + Logger.ERROR(FQRN + " not found. [NULL]"); return null; } } @SuppressWarnings("unused") - public static ItemStack simpleMetaStack(final Item item, final int meta, final int size){ + public static ItemStack simpleMetaStack(final Item item, final int meta, final int size) { try { - if (item == null){ + if (item == null) { return null; } Item em = item; final Item em1 = item; - Logger.WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - if (null == em){ + Logger.WARNING("Found: " + em1.getUnlocalizedName() + ":" + meta); + if (em1 != null) { + if (null == em) { em = em1; } - if (em != null){ - final ItemStack metaStack = new ItemStack(em,size,meta); + if (em != null) { + final ItemStack metaStack = new ItemStack(em, size, meta); return metaStack; } } return null; } catch (final NullPointerException e) { - //Utils.LOG_ERROR(item.getUnlocalizedName()+" not found. [NULL]"); + // Utils.LOG_ERROR(item.getUnlocalizedName()+" not found. [NULL]"); return null; } } @@ -205,10 +216,10 @@ public class ItemUtils { return simpleMetaStack(Item.getItemFromBlock(block), meta, size); } - public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize){ + public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize) { final String oreDict = "ore:"; ItemStack temp; - if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){ + if (fqrn.toLowerCase().contains(oreDict.toLowerCase())) { final String sanitizedName = fqrn.replace(oreDict, ""); temp = ItemUtils.getItemStack(sanitizedName, stackSize); return temp; @@ -217,17 +228,19 @@ public class ItemUtils { String temp1; String temp2; temp1 = fqrnSplit[1]; - if (fqrnSplit.length < 3){temp2 = "0";} - else {temp2 = fqrnSplit[2];} + if (fqrnSplit.length < 3) { + temp2 = "0"; + } else { + temp2 = fqrnSplit[2]; + } temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, temp1, Integer.parseInt(temp2), stackSize); return temp; } public static ItemStack getCorrectStacktype(final Object item_Input, final int stackSize) { - if (item_Input instanceof String){ + if (item_Input instanceof String) { return getItemStackOfAmountFromOreDictNoBroken((String) item_Input, stackSize); - } - else if (item_Input instanceof ItemStack){ + } else if (item_Input instanceof ItemStack) { return (ItemStack) item_Input; } return null; @@ -245,133 +258,160 @@ public class ItemUtils { return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); } - public static void generateSpawnEgg(final String entityModID, final String parSpawnName, final int colourEgg, final int colourOverlay){ - final Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg"); - GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName); + public static void generateSpawnEgg(final String entityModID, final String parSpawnName, final int colourEgg, + final int colourOverlay) { + final Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay) + .setUnlocalizedName("spawn_egg_" + parSpawnName.toLowerCase()) + .setTextureName(CORE.MODID + ":spawn_egg"); + GameRegistry.registerItem(itemSpawnEgg, "spawnEgg" + parSpawnName); } - - public static ItemStack[] validItemsForOreDict(final String oredictName){ + public static ItemStack[] validItemsForOreDict(final String oredictName) { final List<?> validNames = MaterialUtils.oreDictValuesForEntry(oredictName); final ItemStack[] inputs = new ItemStack[validNames.size()]; - for (int i=0; i<validNames.size();i++){ + for (int i = 0; i < validNames.size(); i++) { inputs[i] = (ItemStack) validNames.get(i); } return inputs; } - public static ItemStack getItemStackOfAmountFromOreDict(final String oredictName, final int amount){ + public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, final int amount) { String mTemp = oredictName; - //Banned Materials and replacements for GT5.8 compat. - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - if (oredictName.toLowerCase().contains("rutile")){ - mTemp = oredictName.replace("Rutile", "Titanium"); + + if (oredictName.contains("-") || oredictName.contains("_")) { + mTemp = Utils.sanitizeString(mTemp, new char[] {'-', '_'}); + } + else { + mTemp = Utils.sanitizeString(mTemp); + } + + // Banned Materials and replacements for GT5.8 compat. + + if (oredictName.toLowerCase().contains("ingotclay")) { + return getSimpleStack(Items.clay_ball, amount); } - if (oredictName.toLowerCase().contains("vanadiumsteel")){ - mTemp = oredictName.replace("VanadiumSteel", "StainlessSteel"); - } + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (oredictName.toLowerCase().contains("rutile")) { + mTemp = oredictName.replace("Rutile", "Titanium"); + } + if (oredictName.toLowerCase().contains("vanadiumsteel")) { + mTemp = oredictName.replace("VanadiumSteel", "StainlessSteel"); + } } final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(mTemp); - if (!oreDictList.isEmpty()){ + if (!oreDictList.isEmpty()) { final ItemStack returnValue = oreDictList.get(0).copy(); returnValue.stackSize = amount; return returnValue; } - return getSimpleStack(ModItems.AAA_Broken, amount); + Logger.INFO("Failed to find `" + oredictName + "` in OD."); + return getErrorStack(amount); + //return getItemStackOfAmountFromOreDictNoBroken(mTemp, amount); } - public static ItemStack getItemStackOfAmountFromOreDictNoBroken(final String oredictName, final int amount){ - if (CORE.DEBUG){ - Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(1)); - Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(2)); - Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(3)); - Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(4)); - Logger.WARNING("Looking up: "+oredictName+" - from method: "+ReflectionUtils.getMethodName(5)); - } + public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { + if (CORE.DEBUG) { + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(1)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(2)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(3)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(4)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(5)); + } + + try { - try{ + if (oredictName.contains("-") || oredictName.contains("_")) { + oredictName = Utils.sanitizeString(oredictName, new char[] {'-', '_'}); + } + else { + oredictName = Utils.sanitizeString(oredictName); + } - //Adds a check to grab dusts using GT methodology if possible. + // Adds a check to grab dusts using GT methodology if possible. ItemStack returnValue = null; - if (oredictName.toLowerCase().contains("dust")){ + if (oredictName.toLowerCase().contains("dust")) { final String MaterialName = oredictName.toLowerCase().replace("dust", ""); final Materials m = Materials.get(MaterialName); returnValue = getGregtechDust(m, amount); - if (returnValue != null){ + if (returnValue != null) { return returnValue; } } - if (returnValue == null){ - returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); - if (returnValue != null){ - if ((returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass()) || (returnValue.getItem() != ModItems.AAA_Broken)){ - return returnValue.copy(); - } + /*if (returnValue == null) { + returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); + if (ItemUtils.checkForInvalidItems(returnValue)) { + return returnValue.copy(); } - } - Logger.WARNING(oredictName+" was not valid."); + }*/ + Logger.RECIPE(oredictName + " was not valid."); return null; - } - catch (final Throwable t){ + } catch (final Throwable t) { return null; } } - public static ItemStack getGregtechDust(final Materials material, final int amount){ + public static ItemStack getGregtechDust(final Materials material, final int amount) { final ItemStack returnValue = GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L); - if (returnValue != null){ - if ((returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass()) || (returnValue.getItem() != ModItems.AAA_Broken)){ + if (returnValue != null) { + if ((returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass()) + || (returnValue.getItem() != ModItems.AAA_Broken)) { return returnValue.copy(); } } - Logger.WARNING(material+" was not valid."); + Logger.WARNING(material + " was not valid."); return null; } - //NullFormula - public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, final int Colour){ + // NullFormula + public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, + final int Colour) { return generateSpecialUseDusts(unlocalizedName, materialName, "NullFormula", Colour); } - public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, String mChemForm, final int Colour){ + public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, + String mChemForm, final int Colour) { final Item[] output = { - new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, mChemForm, Colour, "Dust"), - new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, mChemForm, Colour, "Small"), - new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, mChemForm, Colour, "Tiny")}; + new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, mChemForm, Colour, "Dust"), + new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, mChemForm, Colour, "Small"), + new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, mChemForm, Colour, "Tiny") }; return output; } - public static Item generateSpecialUsePlate(final String internalName, final String displayName, final short[] rgb, final int radioactivity){ - return generateSpecialUsePlate(internalName, displayName, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), radioactivity); + public static Item generateSpecialUsePlate(final String internalName, final String displayName, final short[] rgb, + final int radioactivity) { + return generateSpecialUsePlate(internalName, displayName, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), + radioactivity); } - public static Item generateSpecialUsePlate(final String internalName, final String displayName, final String mFormula, final short[] rgb, final int radioactivity){ - return generateSpecialUsePlate(internalName, displayName, mFormula, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), radioactivity); + public static Item generateSpecialUsePlate(final String internalName, final String displayName, + final String mFormula, final short[] rgb, final int radioactivity) { + return generateSpecialUsePlate(internalName, displayName, mFormula, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), + radioactivity); } - public static Item generateSpecialUsePlate(final String internalName, final String displayName, final int rgb, final int radioactivity){ + public static Item generateSpecialUsePlate(final String internalName, final String displayName, final int rgb, + final int radioactivity) { return new BaseItemPlate_OLD(internalName, displayName, rgb, radioactivity); } - public static Item generateSpecialUsePlate(final String internalName, final String displayName, final String mFormula, final int rgb, final int radioactivity){ + public static Item generateSpecialUsePlate(final String internalName, final String displayName, + final String mFormula, final int rgb, final int radioactivity) { return new BaseItemPlate_OLD(internalName, displayName, mFormula, rgb, radioactivity); } - public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust){ + public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust) { final String materialName = material.getLocalizedName(); final String unlocalizedName = Utils.sanitizeString(materialName); final int Colour = material.getRgbAsHex(); Item[] output = null; - if (onlyLargeDust == false){ - output = new Item[]{ - new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"), - new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"), - new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")}; - } else{ - output = new Item[]{ - new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust") - }; + if (onlyLargeDust == false) { + output = new Item[] { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, Colour, "Dust"), + new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, Colour, "Small"), + new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, Colour, "Tiny") }; + } else { + output = new Item[] { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, Colour, "Dust") }; } new RecipeGen_DustGeneration(material); @@ -379,118 +419,99 @@ public class ItemUtils { return output; } - public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final Materials material){ + public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final Materials material) { final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); final int enchantLevel = material.mEnchantmentToolsLevel; final Object enchant = new Pair(material.mEnchantmentTools, enchantLevel); - return generateMultiPick(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, material.mRGBa, enchant); + return generateMultiPick(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, + material.mRGBa, enchant); } - public static MultiPickaxeBase generateMultiPick(final Material material){ + public static MultiPickaxeBase generateMultiPick(final Material material) { final ToolMaterial customMaterial = Utils.generateToolMaterial(material); - return generateMultiPick(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, material.getRGBA(), null); + return generateMultiPick(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, + material.getRGBA(), null); } - public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final ToolMaterial customMaterial, final String name, final int durability, final short[] rgba, final Object enchantment){ - Logger.WARNING("Generating a Multi-Pick out of "+name); + public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final ToolMaterial customMaterial, + final String name, final int durability, final short[] rgba, final Object enchantment) { + Logger.WARNING("Generating a Multi-Pick out of " + name); final short[] rgb = rgba; int dur = customMaterial.getMaxUses(); - Logger.WARNING("Determined durability for "+name+" is "+dur); - if (GT_Durability){ - dur = durability*100; - Logger.WARNING("Using gregtech durability value, "+name+" is now "+dur+"."); - } - else if (dur <= 0){ + Logger.WARNING("Determined durability for " + name + " is " + dur); + if (GT_Durability) { + dur = durability * 100; + Logger.WARNING("Using gregtech durability value, " + name + " is now " + dur + "."); + } else if (dur <= 0) { dur = durability; - Logger.WARNING("Determined durability too low, "+name+" is now "+dur+" based on the GT material durability."); + Logger.WARNING("Determined durability too low, " + name + " is now " + dur + + " based on the GT material durability."); } - if (dur <= 0){ - Logger.WARNING("Still too low, "+name+" will now go unused."); + if (dur <= 0) { + Logger.WARNING("Still too low, " + name + " will now go unused."); return null; } Object enchant; - if (enchantment != null){ - if (enchantment instanceof Pair){ + if (enchantment != null) { + if (enchantment instanceof Pair) { enchant = enchantment; } - } - else { + } else { enchant = null; } - final MultiPickaxeBase MP_Redstone = new MultiPickaxeBase( - name+" Multipick", - (customMaterial), - dur, - Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]), - enchantment); + final MultiPickaxeBase MP_Redstone = new MultiPickaxeBase(name + " Multipick", (customMaterial), dur, + Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), enchantment); - if (MP_Redstone.isValid){ + if (MP_Redstone.isValid) { return MP_Redstone; } Logger.WARNING("Pickaxe was not valid."); return null; } - - - - - - public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final Materials material){ + public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final Materials material) { final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); - return generateMultiShovel(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, material.mRGBa); + return generateMultiShovel(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, + material.mRGBa); } - public static MultiSpadeBase generateMultiShovel(final Material material){ + public static MultiSpadeBase generateMultiShovel(final Material material) { final ToolMaterial customMaterial = Utils.generateToolMaterial(material); - return generateMultiShovel(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, material.getRGBA()); + return generateMultiShovel(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, + material.getRGBA()); } - public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final ToolMaterial customMaterial, final String name, final int durability, final short[] rgba){ - Logger.WARNING("Generating a Multi-Spade out of "+name); + public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final ToolMaterial customMaterial, + final String name, final int durability, final short[] rgba) { + Logger.WARNING("Generating a Multi-Spade out of " + name); final short[] rgb = rgba; int dur = customMaterial.getMaxUses(); - Logger.WARNING("Determined durability for "+name+" is "+dur); - if (GT_Durability){ - dur = durability*100; - Logger.WARNING("Using gregtech durability value, "+name+" is now "+dur+"."); - } - else if (dur <= 0){ + Logger.WARNING("Determined durability for " + name + " is " + dur); + if (GT_Durability) { + dur = durability * 100; + Logger.WARNING("Using gregtech durability value, " + name + " is now " + dur + "."); + } else if (dur <= 0) { dur = durability; - Logger.WARNING("Determined durability too low, "+name+" is now "+dur+" based on the GT material durability."); + Logger.WARNING("Determined durability too low, " + name + " is now " + dur + + " based on the GT material durability."); } - if (dur <= 0){ - Logger.WARNING("Still too low, "+name+" will now go unused."); + if (dur <= 0) { + Logger.WARNING("Still too low, " + name + " will now go unused."); return null; } - final MultiSpadeBase MP_Redstone = new MultiSpadeBase( - name+" Multispade", - (customMaterial), - dur, - Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) - ); + final MultiSpadeBase MP_Redstone = new MultiSpadeBase(name + " Multispade", (customMaterial), dur, + Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2])); - if (MP_Redstone.isValid){ + if (MP_Redstone.isValid) { return MP_Redstone; } return null; } - - - - - - - - - - - - public static BaseItemDecidust generateDecidust(final Materials material){ - if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){ + public static BaseItemDecidust generateDecidust(final Materials material) { + if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null) { final Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); if (placeholder != null) { generateDecidust(placeholder); @@ -499,16 +520,16 @@ public class ItemUtils { return null; } - public static BaseItemDecidust generateDecidust(final Material material){ - if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())){ + public static BaseItemDecidust generateDecidust(final Material material) { + if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())) { final BaseItemDecidust Decidust = new BaseItemDecidust(material); return Decidust; } return null; } - public static BaseItemCentidust generateCentidust(final Materials material){ - if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){ + public static BaseItemCentidust generateCentidust(final Materials material) { + if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null) { final Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); if (placeholder != null) { generateCentidust(placeholder); @@ -517,53 +538,48 @@ public class ItemUtils { return null; } - public static BaseItemCentidust generateCentidust(final Material material){ - if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())){ + public static BaseItemCentidust generateCentidust(final Material material) { + if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())) { final BaseItemCentidust Centidust = new BaseItemCentidust(material); return Centidust; } return null; } - public static boolean isRadioactive(final String materialName){ + public static boolean isRadioactive(final String materialName) { int sRadiation = 0; - if (materialName.toLowerCase().contains("uranium")){ + if (materialName.toLowerCase().contains("uranium")) { sRadiation = 2; - } - else if (materialName.toLowerCase().contains("plutonium")){ + } else if (materialName.toLowerCase().contains("plutonium")) { sRadiation = 4; - } - else if (materialName.toLowerCase().contains("thorium")){ + } else if (materialName.toLowerCase().contains("thorium")) { sRadiation = 1; } - if (sRadiation >= 1){ + if (sRadiation >= 1) { return true; } return false; } - public static int getRadioactivityLevel(final String materialName){ + public static int getRadioactivityLevel(final String materialName) { int sRadiation = 0; - if (materialName.toLowerCase().contains("uranium")){ + if (materialName.toLowerCase().contains("uranium")) { sRadiation = 2; - } - else if (materialName.toLowerCase().contains("plutonium")){ + } else if (materialName.toLowerCase().contains("plutonium")) { sRadiation = 4; - } - else if (materialName.toLowerCase().contains("thorium")){ + } else if (materialName.toLowerCase().contains("thorium")) { sRadiation = 1; } return sRadiation; } - - public static String getArrayStackNames(final FluidStack[] aStack){ + + public static String getArrayStackNames(final FluidStack[] aStack) { String itemNames = "Fluid Array: "; - for (final FluidStack alph : aStack){ - if (alph != null){ + for (final FluidStack alph : aStack) { + if (alph != null) { final String temp = itemNames; itemNames = temp + ", " + alph.getLocalizedName() + " x" + alph.amount; - } - else { + } else { final String temp = itemNames; itemNames = temp + ", " + "null" + " x" + "0"; } @@ -571,15 +587,14 @@ public class ItemUtils { return itemNames; } - public static String getArrayStackNames(final ItemStack[] aStack){ + public static String getArrayStackNames(final ItemStack[] aStack) { String itemNames = "Item Array: "; - for (final ItemStack alph : aStack){ + for (final ItemStack alph : aStack) { - if (alph != null){ + if (alph != null) { final String temp = itemNames; itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; - } - else { + } else { final String temp = itemNames; itemNames = temp + ", " + "null" + " x" + "0"; } @@ -587,10 +602,10 @@ public class ItemUtils { return itemNames; } - public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack){ + public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) { final String[] itemNames = {}; int arpos = 0; - for (final ItemStack alph : aStack){ + for (final ItemStack alph : aStack) { itemNames[arpos] = alph.getDisplayName(); arpos++; } @@ -598,9 +613,9 @@ public class ItemUtils { } - public static String getFluidArrayStackNames(final FluidStack[] aStack){ + public static String getFluidArrayStackNames(final FluidStack[] aStack) { String itemNames = "Fluid Array: "; - for (final FluidStack alph : aStack){ + for (final FluidStack alph : aStack) { final String temp = itemNames; itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; } @@ -608,19 +623,21 @@ public class ItemUtils { } - public static ItemStack getGregtechCircuit(final int Meta){ - return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0); + public static ItemStack getGregtechCircuit(final int Meta) { + return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", + Meta, 0); } + public static ItemStack[] getBlockDrops(final ArrayList<ItemStack> blockDrops) { - if (blockDrops == null){ + if (blockDrops == null) { return null; } - if (blockDrops.isEmpty()){ + if (blockDrops.isEmpty()) { return null; } final ItemStack[] outputs = new ItemStack[blockDrops.size()]; short forCounter = 0; - for (final ItemStack I : blockDrops){ + for (final ItemStack I : blockDrops) { outputs[forCounter++] = I; } return outputs; @@ -628,7 +645,7 @@ public class ItemUtils { private static Map<Item, String> mModidCache = new HashMap<Item, String>(); - private static String getModId(final Item item) { + private static String getModId(final Item item) { if (mModidCache.containsKey(item)) { return mModidCache.get(item); } @@ -639,15 +656,14 @@ public class ItemUtils { final String modname = (id.modId == null ? id.name : id.modId); value = ((id == null) || id.modId.equals("")) ? "minecraft" : modname; } - } catch (final Throwable t){ + } catch (final Throwable t) { try { final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); if (t2 != null) { final String modname = (t2.modId == null ? t2.name : t2.modId); value = ((t2 == null) || t2.modId.equals("")) ? "minecraft" : modname; } - } - catch (final Throwable t3){ + } catch (final Throwable t3) { t3.printStackTrace(); value = "bad modid"; } @@ -662,14 +678,14 @@ public class ItemUtils { return getModId(key.getItem()); } - //Take 2 - GT/GT++ Dusts - public static ItemStack getGregtechDust(final String oredictName, final int amount){ + // Take 2 - GT/GT++ Dusts + public static ItemStack getGregtechDust(final String oredictName, final int amount) { final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); - if (!oreDictList.isEmpty()){ + if (!oreDictList.isEmpty()) { ItemStack returnvalue; - for (int xrc=0;xrc<oreDictList.size();xrc++){ + for (int xrc = 0; xrc < oreDictList.size(); xrc++) { final String modid = getModId(oreDictList.get(xrc).getItem()); - if (modid != null && (modid.equals("gregtech") || modid.equals(CORE.MODID))){ + if (modid != null && (modid.equals("gregtech") || modid.equals(CORE.MODID))) { returnvalue = oreDictList.get(xrc).copy(); returnvalue.stackSize = amount; return returnvalue; @@ -679,192 +695,202 @@ public class ItemUtils { return getNonTinkersDust(oredictName, amount); } - //Anything But Tinkers Dust - public static ItemStack getNonTinkersDust(final String oredictName, final int amount){ + // Anything But Tinkers Dust + public static ItemStack getNonTinkersDust(final String oredictName, final int amount) { final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName); - if (!oreDictList.isEmpty()){ + if (!oreDictList.isEmpty()) { ItemStack returnvalue; - for (int xrc=0;xrc<oreDictList.size();xrc++){ + for (int xrc = 0; xrc < oreDictList.size(); xrc++) { final String modid = getModId(oreDictList.get(xrc).getItem()); - if (modid != null && !modid.equals("tconstruct")){ + if (modid != null && !modid.equals("tconstruct")) { returnvalue = oreDictList.get(xrc).copy(); returnvalue.stackSize = amount; return returnvalue; } } } - //If only Tinkers dust exists, bow down and just use it. + // If only Tinkers dust exists, bow down and just use it. return getItemStackOfAmountFromOreDictNoBroken(oredictName, amount); } + @Deprecated public static ItemStack getGregtechOreStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { + ItemStack aTemp = getOrePrefixStack(mPrefix, mMat, mAmount); + if (aTemp != null) { + return aTemp; + } + String mName = MaterialUtils.getMaterialName(mMat); - String mItemName = mPrefix.name()+mName; - //Utils.LOG_INFO("[Component Maker] Trying to get "+mItemName+"."); - ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDict(mItemName, mAmount); - if (gregstack == null){ - //Utils.LOG_INFO("[Component Maker] Failed to get "+mItemName+"."); + String mItemName = mPrefix.name() + mName; + // Utils.LOG_INFO("[Component Maker] Trying to get "+mItemName+"."); + ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); + if (gregstack == null) { + // Utils.LOG_INFO("[Component Maker] Failed to get "+mItemName+"."); return null; - } - //Utils.LOG_INFO("[Component Maker] Found "+mItemName+"."); + } + // Utils.LOG_INFO("[Component Maker] Found "+mItemName+"."); return (gregstack); } - public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Material mMat, int mAmount) { String mName = Utils.sanitizeString(mMat.getLocalizedName()); - String mItemName = mPrefix.name()+mName; - ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDict(mItemName, mAmount); - if (gregstack == null){ + String mItemName = mPrefix.name() + mName; + ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); + if (gregstack == null) { return null; - } + } return (gregstack); } - + public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { ItemStack aGtStack = GT_OreDictUnificator.get(mPrefix, mMat, mAmount); if (aGtStack == null) { + Logger.INFO( + "Failed to find `" + mPrefix + MaterialUtils.getMaterialName(mMat) + "` in OD. [Prefix Search]"); return getErrorStack(mAmount); - } - else { + } else { return aGtStack; } } public static ItemStack getErrorStack(int mAmount) { + //System.exit(1); + try { + new GregtechException("Logging - [Issue #999]"); + } + catch (Throwable t) { + t.printStackTrace(); + } + return getSimpleStack(ModItems.AAA_Broken, mAmount); + //return null; } - public static ItemStack[] getStackOfAllOreDictGroup(String oredictname){ + + public static ItemStack[] getStackOfAllOreDictGroup(String oredictname) { final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictname); - if (!oreDictList.isEmpty()){ - final ItemStack[] returnValues = new ItemStack[oreDictList.size()]; - for (int i=0;i<oreDictList.size();i++){ - if (oreDictList.get(i) != null){ - returnValues[i] = oreDictList.get(i); + if (!oreDictList.isEmpty()) { + final ItemStack[] returnValues = new ItemStack[oreDictList.size()]; + for (int i = 0; i < oreDictList.size(); i++) { + if (oreDictList.get(i) != null) { + returnValues[i] = oreDictList.get(i); } - } - return returnValues.length>0 ? returnValues : null; - } - else { + } + return returnValues.length > 0 ? returnValues : null; + } else { return null; } } - public static boolean registerFuel(ItemStack aBurnable, int burn){ + public static boolean registerFuel(ItemStack aBurnable, int burn) { return CORE.burnables.add(new Pair<Integer, ItemStack>(burn, aBurnable)); } - /** * Quick Block Name Lookup that is friendly to servers and locale. */ private static volatile Map<String, String> mLocaleCache = new HashMap<String, String>(); + public static String getLocalizedNameOfBlock(BlockPos pos) { Block block = pos.world.getBlock(pos.xPos, pos.yPos, pos.zPos); int metaData = pos.world.getBlockMetadata(pos.xPos, pos.yPos, pos.zPos); - return getLocalizedNameOfBlock(block, metaData); + return getLocalizedNameOfBlock(block, metaData); } - + public synchronized static String getLocalizedNameOfBlock(Block block, int meta) { if (block == null || meta < 0) { return "Bad Block"; } - String mCacheKey = block.getUnlocalizedName()+":"+meta; + String mCacheKey = block.getUnlocalizedName() + ":" + meta; if (mLocaleCache.containsKey(mCacheKey)) { - //Recache the key if it's invalid. + // Recache the key if it's invalid. if (mLocaleCache.get(mCacheKey).toLowerCase().contains(".name")) { mLocaleCache.remove(mCacheKey); String mNew = ItemUtils.simpleMetaStack(block, meta, 1).getDisplayName(); - //Logger.INFO("Re-caching "+mNew+" into locale cache."); + // Logger.INFO("Re-caching "+mNew+" into locale cache."); mLocaleCache.put(mCacheKey, mNew); } return mLocaleCache.get(mCacheKey); - } - else { + } else { Item item = Item.getItemFromBlock(block); if (item == null) { return "Bad Item"; - } + } String unlocalizedName = item.getUnlocalizedName(new ItemStack(block, 1, meta)); - String blockName = StatCollector.translateToLocal(unlocalizedName + ".name"); + String blockName = StatCollector.translateToLocal(unlocalizedName + ".name"); if (blockName.toLowerCase().contains(".name")) { blockName = ItemUtils.simpleMetaStack(block, meta, 1).getDisplayName(); - } + } mLocaleCache.put(mCacheKey, blockName); return blockName; - } + } } - - public static boolean checkForInvalidItems(ItemStack mInput) { - return checkForInvalidItems(new ItemStack[] {mInput}); + return checkForInvalidItems(new ItemStack[] { mInput }); } - + public static boolean checkForInvalidItems(ItemStack[] mInput) { return checkForInvalidItems(mInput, new ItemStack[] {}); } - + /** * * @param mInputs - * @return {@link Boolean} - True if {@link ItemStack}[] only contains valid items. + * @return {@link Boolean} - True if {@link ItemStack}[] only contains valid + * items. */ public static boolean checkForInvalidItems(ItemStack[] mInputs, ItemStack[] mOutputs) { if (mInputs == null || mOutputs == null) { return false; - } + } + if (mInputs.length > 0) { for (ItemStack stack : mInputs) { if (stack != null) { - if (stack.getItem() != null) { - if (stack.getItem() == ModItems.AAA_Broken || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()){ + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken + || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()) { return false; - } - else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()){ + } else if (stack.getItem() == ModItems.ZZZ_Empty + || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()) { return false; - } - else { + } else { continue; } - } - else { + } else { continue; } - } - else { - continue; + } else { + return false; } } - } + } if (mOutputs.length > 0) { for (ItemStack stack : mOutputs) { if (stack != null) { - if (stack.getItem() != null) { - if (stack.getItem() == ModItems.AAA_Broken || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()){ + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken + || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()) { return false; - } - else if (stack.getItem() == ModItems.ZZZ_Empty || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()){ + } else if (stack.getItem() == ModItems.ZZZ_Empty + || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()) { return false; - } - else { + } else { continue; } - } - else { + } else { continue; } - } - else { - continue; + } else { + return false; } } } - + return true; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index 91c546ca30..a5f5c778bf 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -14,6 +14,7 @@ import net.minecraft.item.crafting.IRecipe; import gregtech.api.enums.Materials; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; +import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -23,6 +24,7 @@ import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; @@ -30,6 +32,20 @@ import net.minecraftforge.oredict.ShapelessOreRecipe; public class RecipeUtils { public static int mInvalidID = 1; public static boolean recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9, ItemStack resultItem){ + + if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { + Logger.INFO(ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + Logger.INFO(ReflectionUtils.getMethodName(7)); + Logger.INFO(ReflectionUtils.getMethodName(8)); + Logger.INFO(ReflectionUtils.getMethodName(9)); + System.exit(1); + } + if (resultItem == null){ Logger.RECIPE("[Fix] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); resultItem = ItemUtils.getItemStackOfAmountFromOreDict("givemeabrokenitem", 1); @@ -325,6 +341,21 @@ public static int mInvalidID = 1; InputItem4, InputItem5, InputItem6, InputItem7, InputItem8, InputItem9 }; + + + if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { + Logger.INFO(ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + Logger.INFO(ReflectionUtils.getMethodName(7)); + Logger.INFO(ReflectionUtils.getMethodName(8)); + Logger.INFO(ReflectionUtils.getMethodName(9)); + System.exit(1); + } + int size = COMPAT_HANDLER.mGtRecipesToGenerate.size(); COMPAT_HANDLER.mGtRecipesToGenerate.put(new InternalRecipeObject(o, OutputItem, true)); |