Fabric API

Fabric API

106M Downloads

Fabric api does not support GameStateChangeS2CPacket

lucbf opened this issue ยท 1 comments

commented
new ClientPlayNetworking.PlayChannelHandler() {
                @Override
                public void receive(MinecraftClient minecraftClient, ClientPlayNetworkHandler
                        clientPlayNetworkHandler, PacketByteBuf packetByteBuf, PacketSender packetSender) {
                    GameStateChangeS2CPacket gscs2cp = new GameStateChangeS2CPacket();
                    try {
                        gscs2cp.read(packetByteBuf);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    if (gscs2cp.getReason().equals(MY_STATE_CHANGE))
                        //do stuff
                }
            }

This code doesn't work when registered through net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking.registerGlobalReceiver

commented

Are you sending the exact content of a GameStateChangeS2CPacket in the send method on the same channel that the handler is registered to?

It would be like

var packet = new GameStateChangeS2CPacket(params);
var buf = PacketByteBufs.create()

packet.write(buf)

ServerPlayNetworking.send(player, PACKET_ID, buf)