Fix: Update inventory names (#4106)

Ensure inventory name updates used for e.g. JsonUI work properly.
This commit is contained in:
chris 2023-09-09 00:13:57 +02:00 committed by GitHub
parent acf24d4d6b
commit 007edcbf11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -73,7 +73,8 @@ public class JavaOpenScreenTranslator extends PacketTranslator<ClientboundOpenSc
if (openInventory != null) {
// If the window type is the same, don't close.
// In rare cases, inventories can do funny things where it keeps the same window type up but change the contents.
if (openInventory.getContainerType() != packet.getType()) {
// Or, inventory names can change (useful for JsonUI). In these cases, we need to close the old inventory.
if (openInventory.getContainerType() != packet.getType() || !openInventory.getTitle().equals(name)) {
// Sometimes the server can double-open an inventory with the same ID - don't confirm in that instance.
InventoryUtils.closeInventory(session, openInventory.getJavaId(), openInventory.getJavaId() != packet.getContainerId());
}