From 63643784370e291dd9262855ac73b4ec63b347f3 Mon Sep 17 00:00:00 2001 From: Doug Gabehart Date: Wed, 14 Dec 2016 20:35:43 -0600 Subject: [PATCH] More stability improvements. (Null value and checks to ensure keys exist) --- src/main/java/gregtech/common/items/armor/ArmorData.java | 4 +++- .../common/items/armor/gui/GuiElectricArmor1.java | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/gregtech/common/items/armor/ArmorData.java b/src/main/java/gregtech/common/items/armor/ArmorData.java index 66177360..13f237dd 100644 --- a/src/main/java/gregtech/common/items/armor/ArmorData.java +++ b/src/main/java/gregtech/common/items/armor/ArmorData.java @@ -397,7 +397,9 @@ public class ArmorData { public void change(Map aMap, StatType aType, float aChange){ float tChange = 0; if(aMap==null)System.out.println("changeMapnull"); - if(aMap.containsKey(aType)){tChange = (float) aMap.get(aType); + if(aMap.containsKey(aType)){ + Object value = aMap.get(aType); + tChange = value != null ? (float) aMap.get(aType) : 0.0f; aMap.remove(aType); } aMap.put(aType, (tChange + aChange)); diff --git a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java index 657010f6..50a6a05b 100644 --- a/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java +++ b/src/main/java/gregtech/common/items/armor/gui/GuiElectricArmor1.java @@ -102,12 +102,12 @@ public class GuiElectricArmor1 extends GuiContainer { default: break; } - - if(cont.mInvArmor.data.mStat.get(StatType.TANKCAP)>0){ + float tankCap = cont.mInvArmor.data.mStat.containsKey(StatType.TANKCAP) ? cont.mInvArmor.data.mStat.get(StatType.TANKCAP) :0.0f; + if(tankCap>0){ drawTexturedModalRect(xStart + 94, yStart + 32, 231, 69, 16, 34); } - - int bar = (int) Math.floor(18 * (cont.mInvArmor.data.mStat.get(StatType.WEIGHT)/(float)1000)); + float weight = cont.mInvArmor.data.mStat.containsKey(StatType.WEIGHT) ? cont.mInvArmor.data.mStat.get(StatType.WEIGHT) : 0.0f; + int bar = (int) Math.floor(18 * (weight)/(float)1000); drawTexturedModalRect(xStart + 15, yStart + 7, 217, 26, bar, 5); drawTexturedModalRect(xStart + bar + 15, yStart + 7, 197+bar, 26, 18-bar, 5);