Interface ClientPlayNetworking.PlayPacketHandler<T extends FabricPacket>
- Type Parameters:
T
- the type of the packet
- 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.PlayPacketHandler<T extends FabricPacket>
A thread-safe packet handler utilizing
FabricPacket
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
receive
(T packet, ClientPlayerEntity player, PacketSender responseSender) Handles the incoming packet.
-
Method Details
-
receive
Handles the incoming packet. 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 packet ClientPlayNetworking.registerReceiver(OVERLAY_PACKET_TYPE, (player, packet, responseSender) -> { MinecraftClient.getInstance().inGameHud.setOverlayMessage(packet.message(), true); });
The network handler can be accessed via
ClientPlayerEntity.networkHandler
.- Parameters:
packet
- the packetplayer
- the player that received the packetresponseSender
- the packet sender- See Also:
-