From 999e32f37cf86811d338e4397784de747f86bc44 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Thu, 5 Sep 2019 00:20:13 +0100 Subject: [PATCH] Add lower limit checks for wand cooldown indices in NBT, fixes #155 --- src/main/java/electroblob/wizardry/util/WandHelper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/electroblob/wizardry/util/WandHelper.java b/src/main/java/electroblob/wizardry/util/WandHelper.java index 415076ab..872eeb6d 100644 --- a/src/main/java/electroblob/wizardry/util/WandHelper.java +++ b/src/main/java/electroblob/wizardry/util/WandHelper.java @@ -255,7 +255,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; // Don't need to check if the tag compound is null since the above check is equivalent. return cooldowns[selectedSpell]; } @@ -268,7 +268,7 @@ public final class WandHelper { 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. return cooldowns[nextSpell]; } @@ -281,7 +281,7 @@ public final class WandHelper { 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. return cooldowns[previousSpell]; }