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 Type
    Method
    Description
    void
    receive(T packet, ServerPlayerEntity player, PacketSender responseSender)
    Handles the incoming packet.
  • Method Details

    • receive

      void receive(T packet, ServerPlayerEntity player, PacketSender responseSender)
      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 and ServerPlayerEntity.networkHandler, respectively.

      Parameters:
      packet - the packet
      player - the player that received the packet
      responseSender - the packet sender
      See Also: