From ac73fbc362145bdf0d0aefe126930521fd5dddcb Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 21 Jan 2024 15:57:12 +0000 Subject: [PATCH] Handle play packets on main thread. --- .../impl/networking/client/ClientPlayNetworkAddon.java | 4 +++- .../impl/networking/server/ServerPlayNetworkAddon.java | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/impl/networking/client/ClientPlayNetworkAddon.java b/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/impl/networking/client/ClientPlayNetworkAddon.java index 222fb62ea6..fc3131b45b 100644 --- a/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/impl/networking/client/ClientPlayNetworkAddon.java +++ b/fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/impl/networking/client/ClientPlayNetworkAddon.java @@ -72,7 +72,9 @@ public void onServerReady() { @Override protected void receive(ClientPlayNetworking.PlayPacketHandler handler, CustomPayload payload) { - ((ClientPlayNetworking.PlayPacketHandler) handler).receive(payload, this.client.player, this); + this.client.execute(() -> { + ((ClientPlayNetworking.PlayPacketHandler) handler).receive(payload, client.player, ClientPlayNetworkAddon.this); + }); } // impl details diff --git a/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/server/ServerPlayNetworkAddon.java b/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/server/ServerPlayNetworkAddon.java index e248c425c3..13114aaf24 100644 --- a/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/server/ServerPlayNetworkAddon.java +++ b/fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/server/ServerPlayNetworkAddon.java @@ -62,9 +62,10 @@ public void onClientReady() { } @Override - protected void receive(ServerPlayNetworking.PlayPayloadHandler handler, CustomPayload payload) { - // TODO 1.20.5 fix me - ((ServerPlayNetworking.PlayPayloadHandler) handler).receive(payload, this.handler.player, this); + protected void receive(ServerPlayNetworking.PlayPayloadHandler payloadHandler, CustomPayload payload) { + this.server.execute(() -> { + ((ServerPlayNetworking.PlayPayloadHandler) payloadHandler).receive(payload, ServerPlayNetworkAddon.this.handler.player, ServerPlayNetworkAddon.this); + }); } // impl details