Don't decrement spell index if spells haven't been initialised, and add the missing safety check to getCurrentMaxCooldown - fixes #428

This commit is contained in:
Electroblob77
2020-05-13 12:06:41 +01:00
parent 9205f082f1
commit fe5060a2c0
@@ -217,7 +217,7 @@ public final class WandHelper {
int spellIndex = wand.getTagCompound().getInteger(SELECTED_SPELL_KEY);
if(spellIndex <= 0){
spellIndex = numberOfSpells - 1;
spellIndex = Math.max(0, numberOfSpells - 1);
}else{
spellIndex--;
}
@@ -370,7 +370,7 @@ public final class WandHelper {
int selectedSpell = wand.getTagCompound().getInteger(SELECTED_SPELL_KEY);
if(cooldowns.length <= selectedSpell) return 0;
if(selectedSpell < 0 || cooldowns.length <= selectedSpell) return 0;
return cooldowns[selectedSpell];
}