Interface ClientPlayNetworking.PlayPayloadHandler<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
- 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 net.minecraft.network.protocol.common.custom.CustomPacketPayload>
A thread-safe payload handler utilizing
CustomPacketPayload.-
Method Summary
Modifier and TypeMethodDescriptionvoidreceive(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:
// use PayloadTypeRegistry for registering the payload ClientPlayNetworking.registerReceiver(OVERLAY_PACKET_TYPE, (payload, context) -> { context.client().gui.setOverlayMessage(payload.message(), true); });The packet listener can be accessed via
LocalPlayer.connection.- Parameters:
payload- the packet payloadcontext- the play networking context- See Also:
-