Add lower limit checks for wand cooldown indices in NBT, fixes #155

This commit is contained in:
Electroblob77
2019-09-05 00:20:13 +01:00
parent 8c2ac5adbb
commit 999e32f37c
@@ -255,7 +255,7 @@ public final class WandHelper {
int selectedSpell = wand.getTagCompound().getInteger(SELECTED_SPELL_KEY); int selectedSpell = wand.getTagCompound().getInteger(SELECTED_SPELL_KEY);
if(cooldowns.length <= selectedSpell) return 0; if(selectedSpell < 0 || cooldowns.length <= selectedSpell) return 0;
// Don't need to check if the tag compound is null since the above check is equivalent. // Don't need to check if the tag compound is null since the above check is equivalent.
return cooldowns[selectedSpell]; return cooldowns[selectedSpell];
} }
@@ -268,7 +268,7 @@ public final class WandHelper {
int nextSpell = getNextSpellIndex(wand); int nextSpell = getNextSpellIndex(wand);
if(cooldowns.length <= nextSpell) return 0; if(nextSpell < 0 || cooldowns.length <= nextSpell) return 0;
// Don't need to check if the tag compound is null since the above check is equivalent. // Don't need to check if the tag compound is null since the above check is equivalent.
return cooldowns[nextSpell]; return cooldowns[nextSpell];
} }
@@ -281,7 +281,7 @@ public final class WandHelper {
int previousSpell = getPreviousSpellIndex(wand); int previousSpell = getPreviousSpellIndex(wand);
if(cooldowns.length <= previousSpell) return 0; if(previousSpell < 0 || cooldowns.length <= previousSpell) return 0;
// Don't need to check if the tag compound is null since the above check is equivalent. // Don't need to check if the tag compound is null since the above check is equivalent.
return cooldowns[previousSpell]; return cooldowns[previousSpell];
} }