From 0fab7f258caf332408df5655bbb147018b405f54 Mon Sep 17 00:00:00 2001 From: tahmid-23 <60953955+tahmid-23@users.noreply.github.com> Date: Fri, 14 Jul 2023 22:25:49 -0400 Subject: [PATCH] use packet handler to serialize in the mapeditor --- .../zombies/mapeditor/client/MapeditorClient.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/zombies-mapeditor/src/main/java/org/phantazm/zombies/mapeditor/client/MapeditorClient.java b/zombies-mapeditor/src/main/java/org/phantazm/zombies/mapeditor/client/MapeditorClient.java index fd8f3f230..c95e87462 100644 --- a/zombies-mapeditor/src/main/java/org/phantazm/zombies/mapeditor/client/MapeditorClient.java +++ b/zombies-mapeditor/src/main/java/org/phantazm/zombies/mapeditor/client/MapeditorClient.java @@ -25,7 +25,6 @@ import net.minecraft.client.util.InputUtil; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -95,12 +94,6 @@ public void onInitializeClient() { data -> new PacketByteBufDataReader(new PacketByteBuf(Unpooled.wrappedBuffer(data)))); Identifier clientToProxyIdentifier = Identifier.of(Namespaces.PHANTAZM, MessageChannels.CLIENT_TO_PROXY); if (clientToProxyIdentifier != null) { - ClientPlayConnectionEvents.JOIN.register(((handler, sender, client) -> { - byte[] data = clientToProxy.serializePacket(new MapDataVersionQueryPacket()); - sender.sendPacket(new CustomPayloadC2SPacket(clientToProxyIdentifier, - new PacketByteBuf(Unpooled.wrappedBuffer(data)))); - })); - PacketHandler clientToProxyHandler = new PacketHandler<>(clientToProxy) { @Override protected void handlePacket(@NotNull PacketSender packetSender, @NotNull Packet packet) { @@ -127,6 +120,9 @@ protected void sendToReceiver(@NotNull PacketSender packetSender, byte @NotNull packetSender.sendPacket(clientToProxyIdentifier, new PacketByteBuf(Unpooled.wrappedBuffer(data))); } }; + ClientPlayConnectionEvents.JOIN.register(((handler, sender, client) -> { + clientToProxyHandler.output(sender, new MapDataVersionQueryPacket()); + })); ClientPlayNetworking.registerGlobalReceiver(PhantazmPacket.TYPE, ((packet, player, responseSender) -> { clientToProxyHandler.handleData(responseSender, packet.data()); }));