Interface PacketConsumer

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@Deprecated @FunctionalInterface public interface PacketConsumer
Deprecated.
See the corresponding play packet handler in ClientPlayNetworking or ServerPlayNetworking
Interface for receiving CustomPayload-based packets.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(PacketContext context, net.minecraft.network.PacketByteBuf buffer)
    Deprecated.
    Receive a CustomPayload-based packet.
  • Method Details

    • accept

      void accept(PacketContext context, net.minecraft.network.PacketByteBuf buffer)
      Deprecated.
      Receive a CustomPayload-based packet.

      The PacketByteBuf received will be released as soon as the method exits, meaning that you have to call .retain()/.release() on it if you want to keep it around after that.

      Please keep in mind that this CAN be called OUTSIDE of the main thread! Most game operations are not thread-safe, so you should look into using the thread task queue (PacketContext.getTaskQueue()) to split the "reading" (which should happen within this method's execution) and "applying" (which, unless you know what you're doing, should happen on the main thread, after this method exits).

      Parameters:
      context - The context (receiving player, side, etc.)
      buffer - The byte buffer containing the received packet data.