Record Class PayloadRegistration<T extends net.minecraft.network.protocol.common.custom.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 net.minecraft.network.protocol.common.custom.CustomPacketPayload>(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> codec, IPayloadHandler<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> handler, List<net.minecraft.network.ConnectionProtocol> protocols, Optional<net.minecraft.network.protocol.PacketFlow> flow, String version, boolean optional) extends Record
Holds the information needed to describe a registered payload.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T>
    The field for the codec record component.
    private final Optional<net.minecraft.network.protocol.PacketFlow>
    The field for the flow record component.
    private final IPayloadHandler<T>
    The field for the handler record component.
    private final boolean
    The field for the optional record component.
    private final List<net.minecraft.network.ConnectionProtocol>
    The field for the protocols record component.
    private final net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T>
    The field for the type record component.
    private final String
    The field for the version record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PayloadRegistration(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, IPayloadHandler<T> handler, List<net.minecraft.network.ConnectionProtocol> protocols, Optional<net.minecraft.network.protocol.PacketFlow> flow, String version, boolean optional)
    Creates an instance of a PayloadRegistration record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T>
    Returns the value of the codec record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Optional<net.minecraft.network.protocol.PacketFlow>
    Returns the value of the flow record component.
    Returns the value of the handler record component.
    final int
    Returns a hash code value for this object.
    net.minecraft.resources.ResourceLocation
    id()
     
    boolean
    matchesFlow(net.minecraft.network.protocol.PacketFlow flow)
    Returns true if the registered flow is compatible with the passed flow.
    boolean
    Returns the value of the optional record component.
    List<net.minecraft.network.ConnectionProtocol>
    Returns the value of the protocols record component.
    final String
    Returns a string representation of this record class.
    net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T>
    Returns the value of the type record component.
    Returns the value of the version record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • type

      private final net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type
      The field for the type record component.
    • codec

      private final net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> codec
      The field for the codec record component.
    • handler

      private final IPayloadHandler<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> handler
      The field for the handler record component.
    • protocols

      private final List<net.minecraft.network.ConnectionProtocol> protocols
      The field for the protocols record component.
    • flow

      private final Optional<net.minecraft.network.protocol.PacketFlow> flow
      The field for the flow record component.
    • version

      private final String version
      The field for the version record component.
    • optional

      private final boolean optional
      The field for the optional record component.
  • Constructor Details

    • PayloadRegistration

      public PayloadRegistration(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, IPayloadHandler<T> handler, List<net.minecraft.network.ConnectionProtocol> protocols, Optional<net.minecraft.network.protocol.PacketFlow> flow, String version, boolean optional)
      Creates an instance of a PayloadRegistration record class.
      Parameters:
      type - the value for the type record component
      codec - the value for the codec record component
      handler - the value for the handler record component
      protocols - the value for the protocols record component
      flow - the value for the flow record component
      version - the value for the version record component
      optional - the value for the optional record component
  • Method Details

    • id

      public net.minecraft.resources.ResourceLocation id()
    • matchesFlow

      public boolean matchesFlow(net.minecraft.network.protocol.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 net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • codec

      public net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.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<net.minecraft.network.ConnectionProtocol> protocols()
      Returns the value of the protocols record component.
      Returns:
      the value of the protocols record component
    • flow

      public Optional<net.minecraft.network.protocol.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