Interface ServerPlayNetworking.PlayPayloadHandler<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
- 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.PlayPayloadHandler<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
A thread-safe packet handler utilizing
CustomPacketPayload.-
Method Summary
Modifier and TypeMethodDescriptionvoidreceive(T payload, ServerPlayNetworking.Context context) 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:
// use PayloadTypeRegistry for registering the payload ServerPlayNetworking.registerReceiver(BoomPayload.TYPE, (payload, context) -> { ModPacketHandler.createExplosion(context.player(), payload.fire()); });The packet listener can be accessed via
ServerPlayer.connection.- Parameters:
payload- the packet payloadcontext- the play networking context- See Also:
-