diff --git a/src/main/java/gregtech/common/items/armor/components/ArmorComponent.java b/src/main/java/gregtech/common/items/armor/components/ArmorComponent.java index ea2f0184..3dfcdd17 100644 --- a/src/main/java/gregtech/common/items/armor/components/ArmorComponent.java +++ b/src/main/java/gregtech/common/items/armor/components/ArmorComponent.java @@ -2,6 +2,7 @@ package gregtech.common.items.armor.components; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; +import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gregtech.common.items.armor.ArmorData; import net.minecraft.item.ItemStack; @@ -18,27 +19,37 @@ public abstract class ArmorComponent implements IArmorComponent { public static Map mStacks = new HashMap(); public Map mStat = new HashMap(); public Map mBStat = new HashMap(); - + public ArmorComponent(String aName, String aOreDict, boolean aElectric, float aWeight){ - mConfigName = aName; - if(!GregTech_API.sModularArmor.get( mConfigName, "Enabled", true))return; - mOreDict = GregTech_API.sModularArmor.get( mConfigName, "OreDict", aOreDict); - mBStat.put(StatType.ELECTRIC, aElectric); - mOreDicts.put(aOreDict, this); - for(ItemStack tStack : OreDictionary.getOres(aOreDict))if(tStack!=null)mStacks.put(tStack.getUnlocalizedName(), this); - mStat.put(StatType.WEIGHT, (float) GregTech_API.sModularArmor.get( mConfigName, "Weight", aWeight)); + try { + mConfigName = aName; + if(!GregTech_API.sModularArmor.get( mConfigName, "Enabled", true))return; + mOreDict = GregTech_API.sModularArmor.get( mConfigName, "OreDict", aOreDict); + mBStat.put(StatType.ELECTRIC, aElectric); + mOreDicts.put(aOreDict, this); + for(ItemStack tStack : OreDictionary.getOres(aOreDict))if(tStack!=null)mStacks.put(tStack.getUnlocalizedName(), this); + mStat.put(StatType.WEIGHT, (float) GregTech_API.sModularArmor.get( mConfigName, "Weight", aWeight)); + } + catch (Throwable t){ + GT_Log.out.println("Tried adding "+aName+" as a modular armour component, however it failed."); + } } - + public ArmorComponent(String aName, ItemStack aStack, boolean aElectric, float aWeight){ - mConfigName = aName; - String tStackName = GregTech_API.sModularArmor.get( mConfigName, "Stack", GameRegistry.findUniqueIdentifierFor(aStack.getItem()).toString()+(aStack.getItemDamage()==0 ? "" : ":"+aStack.getItemDamage())); - mStack = GameRegistry.findItemStack(tStackName.split(":")[0], tStackName.split(":")[1], 1); - if(tStackName.split(":").length>2)mStack.setItemDamage(Integer.parseInt(tStackName.split(":")[2])); - if(!GregTech_API.sModularArmor.get( mConfigName, "Enabled", true))return; - mStack = aStack; - mBStat.put(StatType.ELECTRIC, aElectric); - mStacks.put(aStack.getUnlocalizedName(), this); - mStat.put(StatType.WEIGHT, (float) GregTech_API.sModularArmor.get( mConfigName, "Weight", aWeight)); + try { + mConfigName = aName; + String tStackName = GregTech_API.sModularArmor.get( mConfigName, "Stack", GameRegistry.findUniqueIdentifierFor(aStack.getItem()).toString()+(aStack.getItemDamage()==0 ? "" : ":"+aStack.getItemDamage())); + mStack = GameRegistry.findItemStack(tStackName.split(":")[0], tStackName.split(":")[1], 1); + if(tStackName.split(":").length>2)mStack.setItemDamage(Integer.parseInt(tStackName.split(":")[2])); + if(!GregTech_API.sModularArmor.get( mConfigName, "Enabled", true))return; + mStack = aStack; + mBStat.put(StatType.ELECTRIC, aElectric); + mStacks.put(aStack.getUnlocalizedName(), this); + mStat.put(StatType.WEIGHT, (float) GregTech_API.sModularArmor.get( mConfigName, "Weight", aWeight)); + } + catch (Throwable t){ + GT_Log.out.println("Tried adding "+aName+" as a modular armour component, however it failed."); + } } @Override @@ -49,12 +60,12 @@ public abstract class ArmorComponent implements IArmorComponent { if(GT_Utility.areStacksEqual(tStack, aStack, true))return true;} return false; } - + public void addVal(StatType aType, ArmorData aArmorData){ float tArmorDef = 0.0f; if(aArmorData.mStat.containsKey(aType)){ - tArmorDef = aArmorData.mStat.get(aType); - aArmorData.mStat.remove(aType);} + tArmorDef = aArmorData.mStat.get(aType); + aArmorData.mStat.remove(aType);} aArmorData.mStat.put(aType, tArmorDef + mStat.get(aType)); }