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:
Ursprung
7beedb46f8
Commit
d7eef7aaeb
@ -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) {
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren