From 0669f5eb9d5029a8b94ec552171b0837605f7747 Mon Sep 17 00:00:00 2001 From: draknyte1 Date: Fri, 4 Nov 2016 15:23:26 +1000 Subject: $ Cleaned up the entire project. > Much neat, very nices. --- src/Java/gtPlusPlus/core/util/item/ItemUtils.java | 672 +++++++++++----------- 1 file changed, 351 insertions(+), 321 deletions(-) (limited to 'src/Java/gtPlusPlus/core/util/item') diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index e6e36caf25..c8b9848c9f 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -30,243 +30,329 @@ import net.minecraftforge.oredict.OreDictionary; public class ItemUtils { - public static ItemStack getSimpleStack(Item x){ - return getSimpleStack(x, 1); - } - public static ItemStack getSimpleStack(Item x, int i){ + public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName) { try { - ItemStack r = new ItemStack(x, i); - return r; - } catch(Throwable e){ - return null; + GT_OreDictUnificator.registerOre(oreDictName, stack); + } + catch (final NullPointerException e) { + Utils.LOG_ERROR(stack.getDisplayName() + " not registered. [NULL]"); } } - public static ItemStack getSimpleStack(ItemStack x, int i){ - try { - ItemStack r = x.copy(); - r.stackSize = i; - return r; - } catch(Throwable e){ - return null; + + 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 ItemStack getIC2Cell(String S){ - ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+S, 1); + 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) { + ItemUtils.generateCentidust(placeholder); + } + } + return null; + } - if (moreTemp == null){ - int cellID = 0; - ItemStack temp =GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); - return temp != null ? temp : null; + 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; + } - return moreTemp; + 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) { + ItemUtils.generateDecidust(placeholder); + } + } + return null; } - public static ItemStack getIC2Cell(int meta){ - ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta); - return temp != null ? temp : null; + public static Item[] generateDusts(final String unlocalizedName, final String materialName, final int materialTier, + final Material matInfo, final int Colour) { + final int radioactive = ItemUtils.getRadioactivityLevel(materialName); + final Item[] output = { + new BaseItemDust("itemDust" + unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, + radioactive), + new BaseItemDust("itemDustSmall" + unlocalizedName, materialName, matInfo, Colour, "Small", + materialTier, radioactive), + new BaseItemDust("itemDustTiny" + unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, + radioactive) + }; + return output; } + public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final Materials material) { + final ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); + Utils.LOG_WARNING("Generating a Multi-Pick out of " + material.name()); + short[] rgb; + rgb = material.getRGBA(); + int dur = customMaterial.getMaxUses(); + Utils.LOG_WARNING("Determined durability for " + material.name() + " is " + dur); + if (GT_Durability) { + dur = material.mDurability * 100; + Utils.LOG_WARNING("Using gregtech durability value, " + material.name() + " is now " + dur + "."); + } + else if (dur <= 0) { + dur = material.mDurability; + Utils.LOG_WARNING("Determined durability too low, " + material.name() + " is now " + dur + + " based on the GT material durability."); + } - public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){ - try { - Item em = null; - Item em1 = getItem(FQRN); - Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - em = em1; - } - if (em != null){ + if (dur <= 0) { + Utils.LOG_WARNING("Still too low, " + material.name() + " will now go unused."); + return null; + } - ItemStack metaStack = new ItemStack(em,1,meta); - GT_OreDictUnificator.registerOre(oreDictName, metaStack); + final MultiPickaxeBase MP_Redstone = new MultiPickaxeBase(material.name() + " Multipick", customMaterial, dur, + Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2])); - /*ItemStack itemStackWithMeta = new ItemStack(em,1,meta); - GT_OreDictUnificator.registerOre(oreDictName, new ItemStack(itemStackWithMeta.getItem()));*/ - } - } catch (NullPointerException e) { - Utils.LOG_ERROR(itemName+" not found. [NULL]"); + if (MP_Redstone.isValid) { + return MP_Redstone; } + return null; + } - public static void addItemToOreDictionary(ItemStack stack, String oreDictName){ - try { - GT_OreDictUnificator.registerOre(oreDictName, stack); - } catch (NullPointerException e) { - Utils.LOG_ERROR(stack.getDisplayName()+" not registered. [NULL]"); + public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final Materials material) { + final ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); + Utils.LOG_WARNING("Generating a Multi-Shovel out of " + material.name()); + short[] rgb; + rgb = material.getRGBA(); + int dur = customMaterial.getMaxUses(); + Utils.LOG_WARNING("Determined durability for " + material.name() + " is " + dur); + if (GT_Durability) { + dur = material.mDurability * 100; + Utils.LOG_WARNING("Using gregtech durability value, " + material.name() + " is now " + dur + "."); + } + else if (dur <= 0) { + dur = material.mDurability; + Utils.LOG_WARNING("Determined durability too low, " + material.name() + " is now " + dur + + " based on the GT material durability."); } - } - @SuppressWarnings("unused") - public static ItemStack getItemStackWithMeta(boolean MOD, String FQRN, String itemName, int meta, int itemstackSize){ - if (MOD){ - try { - Item em = null; - Item em1 = getItem(FQRN); - Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - if (null == em){ - em = em1; - } - if (em != null){ - ItemStack metaStack = new ItemStack(em,itemstackSize,meta); - return metaStack; - } - } - return null; - } catch (NullPointerException e) { - Utils.LOG_ERROR(itemName+" not found. [NULL]"); - return null; - } + if (dur <= 0) { + Utils.LOG_WARNING("Still too low, " + material.name() + " will now go unused."); + return null; + } + + final MultiSpadeBase MP_Redstone = new MultiSpadeBase(material.name() + " Multishovel", customMaterial, dur, + Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2])); + + if (MP_Redstone.isValid) { + return MP_Redstone; } return null; + } - @SuppressWarnings("unused") - public static ItemStack simpleMetaStack(String FQRN, int meta, int itemstackSize){ - try { - Item em = null; - Item em1 = getItem(FQRN); - Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - if (null == em){ - em = em1; - } - if (em != null){ - ItemStack metaStack = new ItemStack(em,itemstackSize,meta); - return metaStack; - } - } - return null; - } catch (NullPointerException e) { - Utils.LOG_ERROR(FQRN+" not found. [NULL]"); - return null; - } + 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); } - @SuppressWarnings("unused") - public static ItemStack simpleMetaStack(Item item, int meta, int itemstackSize){ - try { - Item em = item; - Item em1 = item; - Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - if (null == em){ - em = em1; - } - if (em != null){ - ItemStack metaStack = new ItemStack(em,itemstackSize,meta); - return metaStack; - } + public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, + final int Colour) { + final Item[] output = { + new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, Colour, "Dust"), + new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, Colour, "Small"), + new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, Colour, "Tiny") + }; + return output; + } + + public static String getArrayStackNames(final ItemStack[] aStack) { + String itemNames = "Item Array: "; + for (final ItemStack alph : aStack) { + + if (alph != null) { + final String temp = itemNames; + itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; } - return null; - } catch (NullPointerException e) { - Utils.LOG_ERROR(item.getUnlocalizedName()+" not found. [NULL]"); - return null; - } + else { + final String temp = itemNames; + itemNames = temp + ", " + "null" + " x" + "0"; + } + } + return itemNames; + } - public static ItemStack getCorrectStacktype(String fqrn, int stackSize){ - String oreDict = "ore:"; - ItemStack temp; - if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){ - String sanitizedName = fqrn.replace(oreDict, ""); - temp = ItemUtils.getItemStack(sanitizedName, stackSize); - return temp; + public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) { + final String[] itemNames = {}; + int arpos = 0; + for (final ItemStack alph : aStack) { + itemNames[arpos] = alph.getDisplayName(); + arpos++; } - String[] fqrnSplit = fqrn.split(":"); - if(fqrnSplit[2] == null){fqrnSplit[2] = "0";} - temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize); - return temp; - } + return itemNames; + + } - public static ItemStack getCorrectStacktype(Object item_Input, int stackSize) { - if (item_Input instanceof String){ - return getCorrectStacktype(item_Input, stackSize); + public static ItemStack getCorrectStacktype(final Object item_Input, final int stackSize) { + if (item_Input instanceof String) { + return ItemUtils.getCorrectStacktype(item_Input, stackSize); } - else if (item_Input instanceof ItemStack){ + else if (item_Input instanceof ItemStack) { return (ItemStack) item_Input; } - if (item_Input instanceof var){ + if (item_Input instanceof var) { return ((var) item_Input).getStack(stackSize); } return null; } - public static Item getItem(String fqrn) // fqrn = fully qualified resource name - { - String[] fqrnSplit = fqrn.split(":"); - return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); + public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize) { + final String oreDict = "ore:"; + ItemStack temp; + if (fqrn.toLowerCase().contains(oreDict.toLowerCase())) { + final String sanitizedName = fqrn.replace(oreDict, ""); + temp = ItemUtils.getItemStack(sanitizedName, stackSize); + return temp; + } + final String[] fqrnSplit = fqrn.split(":"); + if (fqrnSplit[2] == null) { + fqrnSplit[2] = "0"; + } + temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), + stackSize); + return temp; } - public static ItemStack getItemStack(String fqrn, int Size) // fqrn = fully qualified resource name - { - String[] fqrnSplit = fqrn.split(":"); - return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + // TODO + /* + * public static FluidStack getFluidStack(Materials m, int Size) // fqrn = + * fully qualified resource name { String[] fqrnSplit = fqrn.split(":"); + * + * FluidStack x = (FluidStack) "Materials."+m+".getFluid"(Size); + * + * return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); } + */ + + public static String getFluidArrayStackNames(final FluidStack[] aStack) { + String itemNames = "Fluid Array: "; + for (final FluidStack alph : aStack) { + final String temp = itemNames; + itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; + } + return itemNames; + } - // TODO - /*public static FluidStack getFluidStack(Materials m, int Size) // fqrn = fully qualified resource name - { - String[] fqrnSplit = fqrn.split(":"); + public static ItemStack getGregtechCircuit(final int Meta) { + return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", + Meta, 0); + } - FluidStack x = (FluidStack) "Materials."+m+".getFluid"(Size); + public static ItemStack getIC2Cell(final int meta) { + final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta); + return temp != null ? temp : null; + } - return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); - }*/ + public static ItemStack getIC2Cell(final String S) { + final ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + S, 1); + if (moreTemp == null) { + final int cellID = 0; + final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); + return temp != null ? temp : null; + } - public static void generateSpawnEgg(String entityModID, String parSpawnName, int colourEgg, int colourOverlay){ - Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay).setUnlocalizedName("spawn_egg_"+parSpawnName.toLowerCase()).setTextureName(CORE.MODID+":spawn_egg"); - GameRegistry.registerItem(itemSpawnEgg, "spawnEgg"+parSpawnName); + return moreTemp; } + public static Item getItem(final String fqrn) // fqrn = fully qualified + // resource name + { + final String[] fqrnSplit = fqrn.split(":"); + return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); + } - public static ItemStack[] validItemsForOreDict(String oredictName){ - List validNames = MaterialUtils.oreDictValuesForEntry(oredictName); - ItemStack[] inputs = null; - for (int i=0; i oreDictList = OreDictionary.getOres(oredictName); - if (!oreDictList.isEmpty()){ - ItemStack returnValue = oreDictList.get(0).copy(); + public static ItemStack getItemStack(final String fqrn, final int Size) // fqrn + // = + // fully + // qualified + // resource + // name + { + final String[] fqrnSplit = fqrn.split(":"); + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + } + + public static ItemStack getItemStackOfAmountFromOreDict(final String oredictName, final int amount) { + final ArrayList oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()) { + final ItemStack returnValue = oreDictList.get(0).copy(); returnValue.stackSize = amount; return returnValue; } - return getSimpleStack(ModItems.AAA_Broken, amount); + return ItemUtils.getSimpleStack(ModItems.AAA_Broken, amount); } - public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, int amount){ - ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); + public static ItemStack getItemStackOfAmountFromOreDictNoBroken(final String oredictName, final int amount) { + final ItemStack returnValue = ItemUtils.getItemStackOfAmountFromOreDict(oredictName, amount); - if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){ + if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() + || returnValue.getItem() != ModItems.AAA_Broken) { return returnValue; } - Utils.LOG_INFO(oredictName+" was not valid."); + Utils.LOG_INFO(oredictName + " was not valid."); return null; } - public static ItemStack getItemStackOfAmountFromOreDictNoBrokenExcluding(String excludeModName, String oredictName, int amount){ - ItemStack returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); + public static ItemStack getItemStackOfAmountFromOreDictNoBrokenExcluding(final String excludeModName, + final String oredictName, final int amount) { + ItemStack returnValue = ItemUtils.getItemStackOfAmountFromOreDict(oredictName, amount); - if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() || returnValue.getItem() != ModItems.AAA_Broken){ - if (returnValue.getClass().toString().toLowerCase().contains(excludeModName.toLowerCase())){ - ArrayList oreDictList = OreDictionary.getOres(oredictName); - if (!oreDictList.isEmpty()){ + if (returnValue.getItem().getClass() != ModItems.AAA_Broken.getClass() + || returnValue.getItem() != ModItems.AAA_Broken) { + if (returnValue.getClass().toString().toLowerCase().contains(excludeModName.toLowerCase())) { + final ArrayList oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()) { returnValue = oreDictList.get(1).copy(); returnValue.stackSize = amount; return returnValue; } - } + } else { - ArrayList oreDictList = OreDictionary.getOres(oredictName); - if (!oreDictList.isEmpty()){ + final ArrayList oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()) { returnValue = oreDictList.get(1).copy(); returnValue.stackSize = amount; return returnValue; @@ -274,202 +360,146 @@ public class ItemUtils { } return returnValue; } - Utils.LOG_INFO(oredictName+" was not valid."); + Utils.LOG_INFO(oredictName + " was not valid."); return null; } - public static Item[] generateDusts(String unlocalizedName, String materialName, int materialTier, Material matInfo, int Colour){ - int radioactive = getRadioactivityLevel(materialName); - Item[] output = { - new BaseItemDust("itemDust"+unlocalizedName, materialName, matInfo, Colour, "Dust", materialTier, radioactive), - new BaseItemDust("itemDustSmall"+unlocalizedName, materialName, matInfo, Colour, "Small", materialTier, radioactive), - new BaseItemDust("itemDustTiny"+unlocalizedName, materialName, matInfo, Colour, "Tiny", materialTier, radioactive)}; - return output; - } - - public static Item[] generateSpecialUseDusts(String unlocalizedName, String materialName, int Colour){ - Item[] output = { - new BaseItemDustUnique("itemDust"+unlocalizedName, materialName, Colour, "Dust"), - new BaseItemDustUnique("itemDustSmall"+unlocalizedName, materialName, Colour, "Small"), - new BaseItemDustUnique("itemDustTiny"+unlocalizedName, materialName, Colour, "Tiny")}; - return output; - } - - public static MultiPickaxeBase generateMultiPick(boolean GT_Durability, Materials material){ - ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); - Utils.LOG_WARNING("Generating a Multi-Pick out of "+material.name()); - short[] rgb; - rgb = material.getRGBA(); - int dur = customMaterial.getMaxUses(); - Utils.LOG_WARNING("Determined durability for "+material.name()+" is "+dur); - if (GT_Durability){ - dur = material.mDurability*100; - Utils.LOG_WARNING("Using gregtech durability value, "+material.name()+" is now "+dur+"."); - } - else if (dur <= 0){ - dur = material.mDurability; - Utils.LOG_WARNING("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); - } - - if (dur <= 0){ - Utils.LOG_WARNING("Still too low, "+material.name()+" will now go unused."); - return null; + @SuppressWarnings("unused") + 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 = ItemUtils.getItem(FQRN); + 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); + return metaStack; + } + } + return null; + } + catch (final NullPointerException e) { + Utils.LOG_ERROR(itemName + " not found. [NULL]"); + return null; + } } - - MultiPickaxeBase MP_Redstone = new MultiPickaxeBase( - material.name()+" Multipick", - (customMaterial), - dur, - Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) - ); - - if (MP_Redstone.isValid){ - return MP_Redstone; - } return null; - } - public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){ - ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); - Utils.LOG_WARNING("Generating a Multi-Shovel out of "+material.name()); - short[] rgb; - rgb = material.getRGBA(); - int dur = customMaterial.getMaxUses(); - Utils.LOG_WARNING("Determined durability for "+material.name()+" is "+dur); - if (GT_Durability){ - dur = material.mDurability*100; - Utils.LOG_WARNING("Using gregtech durability value, "+material.name()+" is now "+dur+"."); + public static int getRadioactivityLevel(final String materialName) { + int sRadiation = 0; + if (materialName.toLowerCase().contains("uranium")) { + sRadiation = 2; } - else if (dur <= 0){ - dur = material.mDurability; - Utils.LOG_WARNING("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); + else if (materialName.toLowerCase().contains("plutonium")) { + sRadiation = 4; } - - if (dur <= 0){ - Utils.LOG_WARNING("Still too low, "+material.name()+" will now go unused."); - return null; + else if (materialName.toLowerCase().contains("thorium")) { + sRadiation = 1; } - - MultiSpadeBase MP_Redstone = new MultiSpadeBase( - material.name()+" Multishovel", - (customMaterial), - dur, - Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) - ); - - if (MP_Redstone.isValid){ - return MP_Redstone; - } - return null; - + return sRadiation; } - public static BaseItemDecidust generateDecidust(Materials material){ - if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){ - Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); - if (placeholder != null) - generateDecidust(placeholder); - } - return null; + public static ItemStack getSimpleStack(final Item x) { + return ItemUtils.getSimpleStack(x, 1); } - public static BaseItemDecidust generateDecidust(Material material){ - if (material.getDust(1) != null && MaterialUtils.hasValidRGBA(material.getRGBA())){ - BaseItemDecidust Decidust = new BaseItemDecidust(material); - return Decidust; + public static ItemStack getSimpleStack(final Item x, final int i) { + try { + final ItemStack r = new ItemStack(x, i); + return r; + } + catch (final Throwable e) { + return null; } - return null; - } - - public static BaseItemCentidust generateCentidust(Materials material){ - if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null){ - Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); - if (placeholder != null) - generateCentidust(placeholder); - } - return null; } - public static BaseItemCentidust generateCentidust(Material material){ - if (material.getDust(1) != null && MaterialUtils.hasValidRGBA(material.getRGBA())){ - BaseItemCentidust Centidust = new BaseItemCentidust(material); - return Centidust; + 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) { + return null; } - return null; } - public static boolean isRadioactive(String materialName){ - int sRadiation = 0; - if (materialName.toLowerCase().contains("uranium")){ + public static boolean isRadioactive(final String materialName) { + int sRadiation = 0; + 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(String materialName){ - int sRadiation = 0; - if (materialName.toLowerCase().contains("uranium")){ - sRadiation = 2; - } - else if (materialName.toLowerCase().contains("plutonium")){ - sRadiation = 4; + @SuppressWarnings("unused") + public static ItemStack simpleMetaStack(final Item item, final int meta, final int itemstackSize) { + try { + Item em = item; + final Item em1 = item; + 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); + return metaStack; + } + } + return null; } - else if (materialName.toLowerCase().contains("thorium")){ - sRadiation = 1; + catch (final NullPointerException e) { + Utils.LOG_ERROR(item.getUnlocalizedName() + " not found. [NULL]"); + return null; } - return sRadiation; } - public static String getArrayStackNames(ItemStack[] aStack){ - String itemNames = "Item Array: "; - for (ItemStack alph : aStack){ - - if (alph != null){ - String temp = itemNames; - itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize; - } - else { - String temp = itemNames; - itemNames = temp + ", " + "null" + " x" + "0"; + @SuppressWarnings("unused") + public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { + try { + Item em = null; + final Item em1 = ItemUtils.getItem(FQRN); + 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); + return metaStack; + } } + return null; } - return itemNames; - - } - - public static String[] getArrayStackNamesAsArray(ItemStack[] aStack){ - String[] itemNames = {}; - int arpos = 0; - for (ItemStack alph : aStack){ - itemNames[arpos] = alph.getDisplayName(); - arpos++; + catch (final NullPointerException e) { + Utils.LOG_ERROR(FQRN + " not found. [NULL]"); + return null; } - return itemNames; - } - public static String getFluidArrayStackNames(FluidStack[] aStack){ - String itemNames = "Fluid Array: "; - for (FluidStack alph : aStack){ - String temp = itemNames; - itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; + public static ItemStack[] validItemsForOreDict(final String oredictName) { + final List validNames = MaterialUtils.oreDictValuesForEntry(oredictName); + final ItemStack[] inputs = null; + for (int i = 0; i < validNames.size(); i++) { + inputs[i] = (ItemStack) validNames.get(i); } - return itemNames; - - } - - public static ItemStack getGregtechCircuit(int Meta){ - return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0); + return inputs; } } -- cgit