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. Packets received by this class must be registered to PayloadTypeRegistry.playC2S() on both ends. Packets sent by this class must be registered to PayloadTypeRegistry.playS2C() on both ends. Packets must be registered before registering any receivers.

This class should be only used for the logical server.

Packet object-based API

This class provides a registration method, utilizing packet objects, registerGlobalReceiver(CustomPayload.Id, PlayPayloadHandler). This handler executes the callback in the server thread, ensuring thread safety.

This payload object-based API involves three classes:

See the documentation on each class for more information.

See Also: