Class ServerPlayNetworking

java.lang.Object
net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking

public final class ServerPlayNetworking extends Object
Offers access to play stage server-side networking functionalities.

Server-side networking functionalities include receiving serverbound packets, sending clientbound packets, and events related to server-side network handlers.

This class should be only used for the logical server.

Packet object-based API

This class provides a classic registration method, registerGlobalReceiver(Identifier, PlayChannelHandler), and a newer method utilizing packet objects, registerGlobalReceiver(PacketType, PlayPacketHandler). For most mods, using the newer method will improve the readability of the code by separating packet reading/writing code to a separate class. Additionally, the newer method executes the callback in the server thread, ensuring thread safety. For this reason using the newer method is highly recommended. The two methods are network-compatible with each other, so long as the buffer contents are read and written in the same order.

The newer, packet object-based API involves three classes:

See the documentation on each class for more information.

See Also: