From d7eef7aaebd7f9aa227a2b3926f0e0a9e1b947b1 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 29 Dec 2021 14:20:34 -0500 Subject: [PATCH] Cache forms until the player has fully initialized --- .../geysermc/geyser/session/cache/FormCache.java | 14 ++++++++++++-- ...drockSetLocalPlayerAsInitializedTranslator.java | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java index 6f7d180de..9985e1e48 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java @@ -52,9 +52,15 @@ public class FormCache { return windowId; } - public int showForm(Form form) { + public void showForm(Form form) { int windowId = addForm(form); + if (session.getUpstream().isInitialized()) { + sendForm(windowId, form); + } + } + + private void sendForm(int windowId, Form form) { ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket(); formRequestPacket.setFormId(windowId); formRequestPacket.setFormData(form.getJsonData()); @@ -68,8 +74,12 @@ public class FormCache { session.scheduleInEventLoop(() -> session.sendUpstreamPacket(latencyPacket), 500, TimeUnit.MILLISECONDS); } + } - return windowId; + public void resendAllForms() { + for (Int2ObjectMap.Entry