Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Small inventory fixes (#1029)
* Increase minimum delay between closing and opening a new window * Fix potential crash when opening player inventory
Dieser Commit ist enthalten in:
Ursprung
d316d3a5a8
Commit
b9846fe797
@ -135,12 +135,15 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPEN_INVENTORY:
|
case OPEN_INVENTORY:
|
||||||
|
if (!session.getInventory().isOpen()) {
|
||||||
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
|
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
|
||||||
containerOpenPacket.setId((byte) 0);
|
containerOpenPacket.setId((byte) 0);
|
||||||
containerOpenPacket.setType(ContainerType.INVENTORY);
|
containerOpenPacket.setType(ContainerType.INVENTORY);
|
||||||
containerOpenPacket.setUniqueEntityId(-1);
|
containerOpenPacket.setUniqueEntityId(-1);
|
||||||
containerOpenPacket.setBlockPosition(entity.getPosition().toInt());
|
containerOpenPacket.setBlockPosition(entity.getPosition().toInt());
|
||||||
session.sendUpstreamPacket(containerOpenPacket);
|
session.sendUpstreamPacket(containerOpenPacket);
|
||||||
|
session.getInventory().setOpen(true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class InventoryUtils {
|
|||||||
translator.prepareInventory(session, inventory);
|
translator.prepareInventory(session, inventory);
|
||||||
//Ensure at least half a second passes between closing and opening a new window
|
//Ensure at least half a second passes between closing and opening a new window
|
||||||
//The client will not open the new window if it is still closing the old one
|
//The client will not open the new window if it is still closing the old one
|
||||||
long delay = 500 - (System.currentTimeMillis() - session.getLastWindowCloseTime());
|
long delay = 700 - (System.currentTimeMillis() - session.getLastWindowCloseTime());
|
||||||
//TODO: find better way to handle double chest delay
|
//TODO: find better way to handle double chest delay
|
||||||
if (translator instanceof DoubleChestInventoryTranslator) {
|
if (translator instanceof DoubleChestInventoryTranslator) {
|
||||||
delay = Math.max(delay, 200);
|
delay = Math.max(delay, 200);
|
||||||
@ -87,6 +87,7 @@ public class InventoryUtils {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Inventory inventory = session.getInventory();
|
Inventory inventory = session.getInventory();
|
||||||
|
inventory.setOpen(false);
|
||||||
InventoryTranslator translator = InventoryTranslator.INVENTORY_TRANSLATORS.get(inventory.getWindowType());
|
InventoryTranslator translator = InventoryTranslator.INVENTORY_TRANSLATORS.get(inventory.getWindowType());
|
||||||
translator.updateInventory(session, inventory);
|
translator.updateInventory(session, inventory);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren