@FunctionalInterface public static interface ServerPlayNetworking.PlayChannelHandler
Modifier and Type | Method and Description |
---|---|
void |
receive(net.minecraft.server.MinecraftServer server,
net.minecraft.server.network.ServerPlayerEntity player,
net.minecraft.server.network.ServerPlayNetworkHandler handler,
net.minecraft.network.PacketByteBuf buf,
PacketSender responseSender)
Handles an incoming packet.
|
void receive(net.minecraft.server.MinecraftServer server, net.minecraft.server.network.ServerPlayerEntity player, net.minecraft.server.network.ServerPlayNetworkHandler handler, net.minecraft.network.PacketByteBuf buf, PacketSender responseSender)
This method is executed on netty's event loops. Modification to the game should be scheduled using the provided Minecraft server instance.
An example usage of this is to create an explosion where the player is looking:
ServerPlayNetworking.registerReceiver(new Identifier("mymod", "boom"), (server, player, handler, buf, responseSender) -&rt; {
boolean fire = buf.readBoolean();
// All operations on the server or world must be executed on the server thread
server.execute(() -&rt; {
ModPacketHandler.createExplosion(player, fire);
});
});
server
- the serverplayer
- the playerhandler
- the network handler that received this packet, representing the player/client who sent the packetbuf
- the payload of the packetresponseSender
- the packet sender