From 2a496524ba5aec9693974fa23bec63b7ddbfc388 Mon Sep 17 00:00:00 2001 From: Dustin Norberg Date: Mon, 21 Sep 2026 07:32:08 -0400 Subject: [PATCH] Fix book screens opening on server thread --- docs/PORTING.md | 4 ++++ gradle.properties | 2 +- .../rivencraft/client/ClientBookInteractionHandler.java | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/PORTING.md b/docs/PORTING.md index 1e9db9a..1820f2d 100644 --- a/docs/PORTING.md +++ b/docs/PORTING.md @@ -80,6 +80,10 @@ all changes to its destination and custom name. Descriptive Book Age references now carry a display name alongside their stable UUID, with backward-compatible decoding for existing UUID-only data. +Version 0.1.5 ensures the book interaction listener opens screens only for the +logical-client event. This avoids calling the render system from the integrated +server thread when a book is used in singleplayer. + The preview code is separated behind a renderer interface and uses an isolated Ponder level. The first iteration supplies the animated loading boundary; the next iteration will add server-authoritative snapshot transport and populate diff --git a/gradle.properties b/gradle.properties index 78a7958..4349649 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,7 +33,7 @@ mod_name=Rivencraft # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=LGPL-3.0-or-later # The mod version. See https://semver.org/ -mod_version=0.1.4 +mod_version=0.1.5 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/net/dnorberg/rivencraft/client/ClientBookInteractionHandler.java b/src/main/java/net/dnorberg/rivencraft/client/ClientBookInteractionHandler.java index a1cb738..f5851bd 100644 --- a/src/main/java/net/dnorberg/rivencraft/client/ClientBookInteractionHandler.java +++ b/src/main/java/net/dnorberg/rivencraft/client/ClientBookInteractionHandler.java @@ -12,6 +12,12 @@ public final class ClientBookInteractionHandler { } public static void onRightClickItem(PlayerInteractEvent.RightClickItem event) { + // NeoForge posts this common event on both logical sides in an + // integrated game. Screens may only be created by the client copy. + if (!event.getEntity().level().isClientSide()) { + return; + } + boolean linkingBook = event.getItemStack().is(ModItems.LINKING_BOOK.get()); boolean descriptiveBook = event.getItemStack().is(ModItems.DESCRIPTIVE_BOOK.get()); if (!linkingBook && !descriptiveBook) {