Skip to content

Commit

Permalink
fix: book of calling sometimes using offhand item
Browse files Browse the repository at this point in the history
finally fixes #1103
  • Loading branch information
klikli-dev committed Mar 31, 2024
1 parent f9609d2 commit 0196afc
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ protected void init() {
this.addRenderableWidget((new ExtendedButton(guiLeft - buttonWidth / 2, guiTop + 60, buttonWidth, 20,
Component.translatable(this.mode.translationKey()), (b) -> {
LocalPlayer player = Minecraft.getInstance().player;
ItemStack stack = player.getItemInHand(player.getUsedItemHand());
ItemStack stack = player.getMainHandItem(); //important: use main hand otherwise we may get a shield or other non-book item here

//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;
if(stack.getItem() instanceof BookOfCallingItem bookOfCallingItem){
this.mode = bookOfCallingItem.nextItemMode(stack);
OccultismPackets.sendToServer(new MessageSetItemMode(((BookOfCallingItem) stack.getItem()).modeValue(this.mode)));
this.init();
}

OccultismPackets.sendToServer(new MessageSetItemMode(((BookOfCallingItem) stack.getItem()).modeValue(this.mode)));
this.init();
})));

boolean showSize = this.mode.hasSize();
Expand Down

0 comments on commit 0196afc

Please sign in to comment.