diff --git a/src/main/java/com/klikli_dev/occultism/common/item/spirit/BookOfCallingItem.java b/src/main/java/com/klikli_dev/occultism/common/item/spirit/BookOfCallingItem.java index 695bbe8d0..22510afae 100644 --- a/src/main/java/com/klikli_dev/occultism/common/item/spirit/BookOfCallingItem.java +++ b/src/main/java/com/klikli_dev/occultism/common/item/spirit/BookOfCallingItem.java @@ -44,6 +44,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -107,6 +108,18 @@ public int modeValue(ItemMode mode) { return this.getItemModes().indexOf(mode) ; } + @Override + public InteractionResultHolder use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { + ItemStack itemStack = pPlayer.getItemInHand(pUsedHand); + if(!pPlayer.isShiftKeyDown() && pLevel.isClientSide) { + ItemMode curr = this.getCurrentItemMode(itemStack); + WorkAreaSize workAreaSize = ItemNBTUtil.getWorkAreaSize(itemStack); + GuiHelper.openBookOfCallingGui(curr, workAreaSize); + } + return super.use(pLevel, pPlayer, pUsedHand); + + } + @Override public InteractionResult useOn(UseOnContext context) { Player player = context.getPlayer(); @@ -178,13 +191,14 @@ public InteractionResult useOn(UseOnContext context) { @Override public InteractionResult interactLivingEntity(ItemStack stack, Player player, LivingEntity target, InteractionHand hand) { - if (target.level().isClientSide) - return InteractionResult.PASS; //Ignore anything that is not a spirit if (!(target instanceof SpiritEntity targetSpirit)) return InteractionResult.PASS; + if (target.level().isClientSide) + return InteractionResult.SUCCESS; + //books can only control the spirit that is bound to them. if (!targetSpirit.getUUID().equals(ItemNBTUtil.getSpiritEntityUUID(stack))) { //re-link book