From 79154f3d0c37174fbba8a305e84b1176e1f239b4 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 4 Mar 2024 00:39:57 +0100 Subject: [PATCH] Fix: Lecterns not opening when there is no lectern cache (#4476) ... the LecternCache doesn't always exist. Oops. --- .../main/java/org/geysermc/geyser/session/GeyserSession.java | 2 +- .../translator/inventory/LecternInventoryTranslator.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index b151f9b09..8bdb41979 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -285,7 +285,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { * See {@link WorldManager#sendLecternData(GeyserSession, int, int, int)} * for more information. */ - private final Set lecternCache; + private final @Nullable Set lecternCache; /** * A list of all players that have a player head on with a custom texture. diff --git a/core/src/main/java/org/geysermc/geyser/translator/inventory/LecternInventoryTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/inventory/LecternInventoryTranslator.java index 26721bfcc..7a1ec7573 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/inventory/LecternInventoryTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/inventory/LecternInventoryTranslator.java @@ -193,9 +193,11 @@ public class LecternInventoryTranslator extends AbstractBlockInventoryTranslator lecternContainer.setPosition(position); BlockEntityUtils.updateBlockEntity(session, blockEntityTag, position); - session.getLecternCache().add(position); if (shouldRefresh) { + // the lectern cache doesn't always exist; only when we must refresh + session.getLecternCache().add(position); + // Close the window - we will reopen it once the client has this data synced ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getJavaId()); session.sendDownstreamGamePacket(closeWindowPacket);