Fabric api does not support GameStateChangeS2CPacket
lucbf opened this issue ยท 1 comments
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
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)