Interface ClientPlayNetworking.PlayPayloadHandler<T extends CustomPayload>
- Type Parameters:
T
- the type of the payload
- Enclosing class:
ClientPlayNetworking
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public static interface ClientPlayNetworking.PlayPayloadHandler<T extends CustomPayload>
A thread-safe payload handler utilizing
CustomPayload
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
receive
(T payload, ClientPlayNetworking.Context context) Handles the incoming payload.
-
Method Details
-
receive
Handles the incoming payload. This is called on the render thread, and can safely call client methods.An example usage of this is to display an overlay message:
// See FabricPacket for creating the payload ClientPlayNetworking.registerReceiver(OVERLAY_PACKET_TYPE, (player, payload, responseSender) -> { MinecraftClient.getInstance().inGameHud.setOverlayMessage(payload.message(), true); });
The network handler can be accessed via
ClientPlayerEntity.networkHandler
.- Parameters:
payload
- the packet payloadcontext
- the play networking context- See Also:
-