Interface ServerPlayNetworking.PlayPacketHandler<T extends FabricPacket>
- Type Parameters:
T
- the type of the packet
- Enclosing class:
ServerPlayNetworking
- 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 ServerPlayNetworking.PlayPacketHandler<T extends FabricPacket>
A thread-safe packet handler utilizing
FabricPacket
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
receive
(T packet, ServerPlayerEntity player, PacketSender responseSender) Handles the incoming packet.
-
Method Details
-
receive
Handles the incoming packet. This is called on the server thread, and can safely manipulate the world.An example usage of this is to create an explosion where the player is looking:
// See FabricPacket for creating the packet ServerPlayNetworking.registerReceiver(BOOM_PACKET_TYPE, (player, packet, responseSender) -> { ModPacketHandler.createExplosion(player, packet.fire()); });
The server and the network handler can be accessed via
ServerPlayerEntity.server
andServerPlayerEntity.networkHandler
, respectively.- Parameters:
packet
- the packetplayer
- the player that received the packetresponseSender
- the packet sender- See Also:
-