Fix: Lecterns not opening when there is no lectern cache (#4476)

... the LecternCache doesn't always exist. Oops.
This commit is contained in:
chris 2024-03-04 00:39:57 +01:00 committed by GitHub
parent 123990a795
commit 79154f3d0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View file

@ -285,7 +285,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
* See {@link WorldManager#sendLecternData(GeyserSession, int, int, int)}
* for more information.
*/
private final Set<Vector3i> lecternCache;
private final @Nullable Set<Vector3i> lecternCache;
/**
* A list of all players that have a player head on with a custom texture.

View file

@ -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);