diff --git a/src/main/java/com/klikli_dev/occultism/client/gui/spirit/BookOfCallingGui.java b/src/main/java/com/klikli_dev/occultism/client/gui/spirit/BookOfCallingGui.java index 0fde11fc4..1abbebf8b 100644 --- a/src/main/java/com/klikli_dev/occultism/client/gui/spirit/BookOfCallingGui.java +++ b/src/main/java/com/klikli_dev/occultism/client/gui/spirit/BookOfCallingGui.java @@ -31,7 +31,6 @@ import com.klikli_dev.occultism.network.MessageSetItemMode; import com.klikli_dev.occultism.network.MessageSetWorkAreaSize; import com.klikli_dev.occultism.network.OccultismPackets; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; @@ -83,13 +82,13 @@ protected void init() { Component.translatable(this.mode.translationKey()), (b) -> { LocalPlayer player = Minecraft.getInstance().player; ItemStack stack = player.getItemInHand(player.getUsedItemHand()); - this.mode = stack.getItem() instanceof BookOfCallingItem ? - ((BookOfCallingItem) stack.getItem()).nextItemMode(stack):null; - if(this.mode!=null) - { - OccultismPackets.sendToServer(new MessageSetItemMode(((BookOfCallingItem)stack.getItem()).modeValue(this.mode))); - this.init(); - } + + //go to the next mode, if the selected item somehow changed keep the old mode. + this.mode = stack.getItem() instanceof BookOfCallingItem bookOfCallingItem ? + bookOfCallingItem.nextItemMode(stack) : this.mode; + + OccultismPackets.sendToServer(new MessageSetItemMode(((BookOfCallingItem) stack.getItem()).modeValue(this.mode))); + this.init(); }))); boolean showSize = this.mode.hasSize(); diff --git a/src/main/java/com/klikli_dev/occultism/util/ItemNBTUtil.java b/src/main/java/com/klikli_dev/occultism/util/ItemNBTUtil.java index 38fc3d5a5..3d54f2de4 100644 --- a/src/main/java/com/klikli_dev/occultism/util/ItemNBTUtil.java +++ b/src/main/java/com/klikli_dev/occultism/util/ItemNBTUtil.java @@ -88,7 +88,6 @@ public static String getBoundSpiritName(ItemStack stack) { } public static int getItemMode(ItemStack stack) { - CompoundTag compound = stack.getTag(); if (!stack.getOrCreateTag().contains(ITEM_MODE_TAG)) setItemMode(stack, 0);