Skip to content

Commit d4733c8

Browse files
committed
Fix: Inventory opening issues related to virtual chest queuing
1 parent 1cbfe34 commit d4733c8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockContainerCloseTranslator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void translate(GeyserSession session, ContainerClosePacket packet) {
6161
} else if (holder.bedrockId() == session.getPendingOrCurrentBedrockInventoryId()) {
6262
// If virtual inventories are opened too quickly, they can be occasionally rejected
6363
// We just try and queue a new one.
64+
holder.inventory().setDisplayed(false);
6465
// Before making another attempt to re-open, let's make sure we actually need this inventory open.
6566
if (holder.containerOpenAttempts() < 7) {
6667
holder.incrementContainerOpenAttempts();

core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,20 @@ public static void openInventory(InventoryHolder<?> holder) {
118118
*/
119119
public static void openPendingInventory(GeyserSession session) {
120120
InventoryHolder<?> holder = session.getInventoryHolder();
121-
if (holder == null || !holder.pending()) {
121+
if (holder == null) {
122122
session.setPendingOrCurrentBedrockInventoryId(-1);
123123
GeyserImpl.getInstance().getLogger().debug(session, "No pending inventory, not opening an inventory! Current inventory: %s", debugInventory(holder));
124124
return;
125125
}
126126

127127
// Current inventory isn't null! Let's see if we need to open it.
128-
if (holder.inventory().getBedrockId() == session.getPendingOrCurrentBedrockInventoryId()) {
128+
if (holder.bedrockId() == session.getPendingOrCurrentBedrockInventoryId()) {
129+
// Don't re-open an inventory that is already open
130+
if (!holder.pending() && holder.inventory().isDisplayed()) {
131+
GeyserImpl.getInstance().getLogger().debug("Container with id %s is not pending and already displayed!".formatted(holder.bedrockId()));
132+
return;
133+
}
134+
129135
GeyserImpl.getInstance().getLogger().debug(session, "Attempting to open currently delayed inventory with matching bedrock id! " + holder.bedrockId());
130136
openAndUpdateInventory(holder);
131137
return;

0 commit comments

Comments
 (0)