From 48c804fcaafa16faefd5bc963d917bee5c69535f Mon Sep 17 00:00:00 2001 From: altrisi Date: Thu, 10 Nov 2022 13:14:03 +0100 Subject: [PATCH] Don't copy (and allocate) `ByteBuf` when reading Carpet packets Should fix #1589 --- .../java/carpet/mixins/ServerGamePacketListenerImplMixin.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java b/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java index 2a1fe5dc..714d8a75 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java @@ -2,7 +2,6 @@ package carpet.mixins; import carpet.network.CarpetClient; import carpet.network.ServerNetworkHandler; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.PacketUtils; import net.minecraft.network.protocol.game.ServerGamePacketListener; import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket; @@ -29,9 +28,8 @@ public class ServerGamePacketListenerImplMixin // We should force onto the main thread here // ServerNetworkHandler.handleData can possibly mutate data that isn't // thread safe, and also allows for client commands to be executed - // [TODO] need to investigate if that is actually an issue since carpet doesn't fiddle with its packets. PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListener) this, player.getLevel()); - ServerNetworkHandler.handleData(new FriendlyByteBuf(packet.getData().copy()), player); + ServerNetworkHandler.handleData(packet.getData(), player); ci.cancel(); } }