diff --git a/src/main/java/com/github/elenterius/biomancy/world/item/GuideBookItem.java b/src/main/java/com/github/elenterius/biomancy/world/item/GuideBookItem.java index f62b9c206..8287cc1e7 100644 --- a/src/main/java/com/github/elenterius/biomancy/world/item/GuideBookItem.java +++ b/src/main/java/com/github/elenterius/biomancy/world/item/GuideBookItem.java @@ -17,6 +17,8 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.extensions.common.IClientItemExtensions; import software.bernie.geckolib3.core.IAnimatable; import software.bernie.geckolib3.core.PlayState; @@ -64,15 +66,20 @@ public InteractionResultHolder use(Level level, Player player, Intera ItemStack stack = player.getItemInHand(usedHand); if (level.isClientSide) { - boolean canOpenBook = ModsCompatHandler.getModonomiconHelper().openBook(GUIDE_BOOK_ID); - if (!canOpenBook && player instanceof LocalPlayer localPlayer) { - Minecraft.getInstance().setScreen(new AdvancementsScreen(localPlayer.connection.getAdvancements())); //fallback - } + tryToOpenClientScreen(player); } return InteractionResultHolder.sidedSuccess(stack, level.isClientSide); } + @OnlyIn(Dist.CLIENT) + private void tryToOpenClientScreen(Player player) { + boolean canOpenBook = ModsCompatHandler.getModonomiconHelper().openBook(GUIDE_BOOK_ID); + if (!canOpenBook && player instanceof LocalPlayer localPlayer) { + Minecraft.getInstance().setScreen(new AdvancementsScreen(localPlayer.connection.getAdvancements())); //fallback + } + } + @Override public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotId, boolean isSelected) { if (level.isClientSide) return;