Record Class PayloadRegistration<T extends CustomPacketPayload>

java.lang.Object
java.lang.Record
net.neoforged.neoforge.network.registration.PayloadRegistration<T>
Type Parameters:
T - The type of the payload
Record Components:
type - The type of the payload
codec - The codec for the payload
handler - The handler for the payload
protocols - The protocols this payload supports
flow - The flow this payload supports (empty if both)
version - The version of the payload
optional - If the payload is optional

@Internal public record PayloadRegistration<T extends CustomPacketPayload>(CustomPacketPayload.Type<T extends CustomPacketPayload> type, StreamCodec<? super RegistryFriendlyByteBuf,T extends CustomPacketPayload> codec, IPayloadHandler<T extends CustomPacketPayload> handler, List<ConnectionProtocol> protocols, Optional<PacketFlow> flow, String version, boolean optional) extends Record
Holds the information needed to describe a registered payload.
  • Field Details

  • Constructor Details

  • Method Details

    • id

      public ResourceLocation id()
    • matchesFlow

      public boolean matchesFlow(PacketFlow flow)
      Returns true if the registered flow is compatible with the passed flow.
      Returns:
      true if the registered flow is compatible with the passed flow
    • 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.
    • type

      public CustomPacketPayload.Type<T> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • codec

      public StreamCodec<? super RegistryFriendlyByteBuf,T> codec()
      Returns the value of the codec record component.
      Returns:
      the value of the codec record component
    • handler

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

      public List<ConnectionProtocol> protocols()
      Returns the value of the protocols record component.
      Returns:
      the value of the protocols record component
    • flow

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

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • optional

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