mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Cache forms until the player has fully initialized
This commit is contained in:
parent
7beedb46f8
commit
d7eef7aaeb
2 changed files with 15 additions and 2 deletions
|
@ -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<Form> entry : forms.int2ObjectEntrySet()) {
|
||||
sendForm(entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void handleResponse(ModalFormResponsePacket response) {
|
||||
|
|
|
@ -55,6 +55,9 @@ public class BedrockSetLocalPlayerAsInitializedTranslator extends PacketTranslat
|
|||
if (session.getOpenInventory() != null && session.getOpenInventory().isPending()) {
|
||||
InventoryUtils.openInventory(session, session.getOpenInventory());
|
||||
}
|
||||
|
||||
// What am I to expect - as of Bedrock 1.18
|
||||
session.getFormCache().resendAllForms();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue