From b0baf1670d0a3b200e0aaaf3b094f4fad98c5a6b Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Tue, 7 Dec 2021 14:51:58 -0500 Subject: [PATCH] Don't send inventories to the client before initialization Fixes #2677 --- .../BedrockSetLocalPlayerAsInitializedTranslator.java | 8 +++++++- .../java/org/geysermc/geyser/util/InventoryUtils.java | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java index b30d9be81..a2c0806b0 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java @@ -30,6 +30,7 @@ import org.geysermc.geyser.session.auth.AuthType; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.Translator; +import org.geysermc.geyser.util.InventoryUtils; import org.geysermc.geyser.util.LoginEncryptionUtils; @Translator(packet = SetLocalPlayerAsInitializedPacket.class) @@ -47,8 +48,13 @@ public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslat // else we were able to log the user in } if (session.isLoggedIn()) { - // Sigh + // Sigh - as of Bedrock 1.18 session.getEntityCache().updateBossBars(); + + // Double sigh - https://github.com/GeyserMC/Geyser/issues/2677 - as of Bedrock 1.18 + if (session.getOpenInventory() != null && session.getOpenInventory().isPending()) { + InventoryUtils.openInventory(session, session.getOpenInventory()); + } } } } diff --git a/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java b/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java index 1b671b2fe..6ab25a177 100644 --- a/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java @@ -66,9 +66,10 @@ public class InventoryUtils { public static void openInventory(GeyserSession session, Inventory inventory) { session.setOpenInventory(inventory); - if (session.isClosingInventory()) { - //Wait for close confirmation from client before opening the new inventory. - //Handled in BedrockContainerCloseTranslator + if (session.isClosingInventory() || !session.getUpstream().isInitialized()) { + // Wait for close confirmation from client before opening the new inventory. + // Handled in BedrockContainerCloseTranslator + // or - client hasn't yet loaded in; wait until inventory is shown inventory.setPending(true); return; }