From fe5060a2c0b25159bea930fc350f59c654805db8 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Wed, 13 May 2020 12:06:41 +0100 Subject: [PATCH] Don't decrement spell index if spells haven't been initialised, and add the missing safety check to getCurrentMaxCooldown - fixes #428 --- src/main/java/electroblob/wizardry/util/WandHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/electroblob/wizardry/util/WandHelper.java b/src/main/java/electroblob/wizardry/util/WandHelper.java index ca8fde07..9dda1184 100644 --- a/src/main/java/electroblob/wizardry/util/WandHelper.java +++ b/src/main/java/electroblob/wizardry/util/WandHelper.java @@ -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]; }