Record Class PlayRegistration<T extends CustomPacketPayload>

java.lang.Object
java.lang.Record
net.neoforged.neoforge.network.registration.PlayRegistration<T>
Type Parameters:
T - The type of the payload
Record Components:
reader - The reader for the payload
handler - The handler for the payload
version - The version of the payload
flow - The flow of the payload
optional - Whether the payload is optional
All Implemented Interfaces:
Function<FriendlyByteBuf,CustomPacketPayload>, FriendlyByteBuf.Reader<CustomPacketPayload>, IPlayPayloadHandler<CustomPacketPayload>

@Internal public record PlayRegistration<T extends CustomPacketPayload>(FriendlyByteBuf.Reader<T extends CustomPacketPayload> reader, IPlayPayloadHandler<T extends CustomPacketPayload> handler, Optional<String> version, Optional<PacketFlow> flow, boolean optional) extends Record implements IPlayPayloadHandler<CustomPacketPayload>, FriendlyByteBuf.Reader<CustomPacketPayload>
A record that holds the information needed to describe a registered play payload, its reader and handler.
  • Field Details

  • Constructor Details

  • Method Details

    • handle

      public void handle(CustomPacketPayload payload, PlayPayloadContext context)
      Description copied from interface: IPlayPayloadHandler
      Invoked to handle the given payload in the given context.
      Specified by:
      handle in interface IPlayPayloadHandler<T extends CustomPacketPayload>
      Parameters:
      payload - The payload.
      context - The context.
    • apply

      public CustomPacketPayload apply(FriendlyByteBuf buffer)
      Specified by:
      apply in interface Function<FriendlyByteBuf,CustomPacketPayload>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • reader

      public FriendlyByteBuf.Reader<T> reader()
      Returns the value of the reader record component.
      Returns:
      the value of the reader record component
    • handler

      public IPlayPayloadHandler<T> handler()
      Returns the value of the handler record component.
      Returns:
      the value of the handler record component
    • version

      public Optional<String> version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • flow

      public Optional<PacketFlow> flow()
      Returns the value of the flow record component.
      Returns:
      the value of the flow record component
    • optional

      public boolean optional()
      Returns the value of the optional record component.
      Returns:
      the value of the optional record component