Yet another AIOOBE fix for WandHelper, fixes #176

Right, I've had enough of this. Why do other people keep getting AIOOBEs from WandHelper when I've never ever had one in my dev environment, after all the testing I've done? What gives?!
This commit is contained in:
Electroblob77
2019-08-18 22:02:47 +01:00
parent a1d2d6a16e
commit 78fc00c0cc
@@ -333,9 +333,13 @@ public final class WandHelper {
int[] cooldowns = getMaxCooldowns(wand);
if(cooldowns.length == 0) return 0;
// Don't need to check if the tag compound is null since the above check is equivalent.
return cooldowns[wand.getTagCompound().getInteger(SELECTED_SPELL_KEY)];
if(wand.getTagCompound() == null) return 0;
int selectedSpell = wand.getTagCompound().getInteger(SELECTED_SPELL_KEY);
if(cooldowns.length <= selectedSpell) return 0;
return cooldowns[selectedSpell];
}
// ================================================== Upgrades ==================================================