3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Cache forms until the player has fully initialized

Dieser Commit ist enthalten in:
Camotoy 2021-12-29 14:20:34 -05:00
Ursprung 7beedb46f8
Commit d7eef7aaeb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 15 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -52,9 +52,15 @@ public class FormCache {
return windowId; return windowId;
} }
public int showForm(Form form) { public void showForm(Form form) {
int windowId = addForm(form); int windowId = addForm(form);
if (session.getUpstream().isInitialized()) {
sendForm(windowId, form);
}
}
private void sendForm(int windowId, Form form) {
ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket(); ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket();
formRequestPacket.setFormId(windowId); formRequestPacket.setFormId(windowId);
formRequestPacket.setFormData(form.getJsonData()); formRequestPacket.setFormData(form.getJsonData());
@ -68,8 +74,12 @@ public class FormCache {
session.scheduleInEventLoop(() -> session.sendUpstreamPacket(latencyPacket), session.scheduleInEventLoop(() -> session.sendUpstreamPacket(latencyPacket),
500, TimeUnit.MILLISECONDS); 500, TimeUnit.MILLISECONDS);
} }
}
return windowId; public void resendAllForms() {
for (Int2ObjectMap.Entry<Form> entry : forms.int2ObjectEntrySet()) {
sendForm(entry.getIntKey(), entry.getValue());
}
} }
public void handleResponse(ModalFormResponsePacket response) { public void handleResponse(ModalFormResponsePacket response) {

Datei anzeigen

@ -55,6 +55,9 @@ public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslat
if (session.getOpenInventory() != null && session.getOpenInventory().isPending()) { if (session.getOpenInventory() != null && session.getOpenInventory().isPending()) {
InventoryUtils.openInventory(session, session.getOpenInventory()); InventoryUtils.openInventory(session, session.getOpenInventory());
} }
// What am I to expect - as of Bedrock 1.18
session.getFormCache().resendAllForms();
} }
} }
} }