Added a failsafe for invalid Modular armour components.

This commit is contained in:
Alkalus 2017-11-05 19:12:48 +10:00
parent 2d8df8d145
commit c4b245af9b

View file

@ -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;
@ -20,6 +21,7 @@ public abstract class ArmorComponent implements IArmorComponent {
public Map<StatType,Boolean> mBStat = new HashMap<StatType,Boolean>();
public ArmorComponent(String aName, String aOreDict, boolean aElectric, float aWeight){
try {
mConfigName = aName;
if(!GregTech_API.sModularArmor.get( mConfigName, "Enabled", true))return;
mOreDict = GregTech_API.sModularArmor.get( mConfigName, "OreDict", aOreDict);
@ -28,8 +30,13 @@ public abstract class ArmorComponent implements IArmorComponent {
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){
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);
@ -40,6 +47,10 @@ public abstract class ArmorComponent implements IArmorComponent {
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
public boolean isArmorComponent(ItemStack aStack) {