From c030629bab262d831d73cc3353e003bdcbca35c1 Mon Sep 17 00:00:00 2001 From: WinDanesz <31292708+windanesz@users.noreply.github.com> Date: Sat, 30 Dec 2023 21:08:07 +0100 Subject: [PATCH] fix: Fixed clear button and Attunement --- src/main/java/electroblob/wizardry/item/ItemWand.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/electroblob/wizardry/item/ItemWand.java b/src/main/java/electroblob/wizardry/item/ItemWand.java index ef6c077b..5fcbe007 100644 --- a/src/main/java/electroblob/wizardry/item/ItemWand.java +++ b/src/main/java/electroblob/wizardry/item/ItemWand.java @@ -899,7 +899,16 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem, ItemStack stack = centre.getStack(); if (stack.hasTagCompound() && stack.getTagCompound().hasKey(WandHelper.SPELL_ARRAY_KEY)) { NBTTagCompound nbt = stack.getTagCompound(); - nbt.removeTag(WandHelper.SPELL_ARRAY_KEY); + int[] spells = nbt.getIntArray(WandHelper.SPELL_ARRAY_KEY); + int expectedSlotCount = BASE_SPELL_SLOTS + WandHelper.getUpgradeLevel(stack, + WizardryItems.attunement_upgrade); + + // unbrick broken wands + if (spells.length < expectedSlotCount) { + spells = new int[expectedSlotCount]; + } + Arrays.fill(spells, 0); + nbt.setIntArray(WandHelper.SPELL_ARRAY_KEY, spells); stack.setTagCompound(nbt); } }