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 payloadcodec
- The codec for the payloadhandler
- The handler for the payloadprotocols
- The protocols this payload supportsflow
- The flow this payload supports (empty if both)version
- The version of the payloadoptional
- 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 Summary
Modifier and TypeFieldDescriptionprivate final StreamCodec
<? super RegistryFriendlyByteBuf, T> The field for thecodec
record component.private final Optional
<PacketFlow> The field for theflow
record component.private final IPayloadHandler
<T> The field for thehandler
record component.private final boolean
The field for theoptional
record component.private final List
<ConnectionProtocol> The field for theprotocols
record component.private final CustomPacketPayload.Type
<T> The field for thetype
record component.private final String
The field for theversion
record component. -
Constructor Summary
ConstructorDescriptionPayloadRegistration
(CustomPacketPayload.Type<T> type, StreamCodec<? super RegistryFriendlyByteBuf, T> codec, IPayloadHandler<T> handler, List<ConnectionProtocol> protocols, Optional<PacketFlow> flow, String version, boolean optional) Creates an instance of aPayloadRegistration
record class. -
Method Summary
Modifier and TypeMethodDescriptionStreamCodec
<? super RegistryFriendlyByteBuf, T> codec()
Returns the value of thecodec
record component.final boolean
Indicates whether some other object is "equal to" this one.flow()
Returns the value of theflow
record component.handler()
Returns the value of thehandler
record component.final int
hashCode()
Returns a hash code value for this object.id()
boolean
matchesFlow
(PacketFlow flow) Returns true if the registered flow is compatible with the passed flow.boolean
optional()
Returns the value of theoptional
record component.Returns the value of theprotocols
record component.final String
toString()
Returns a string representation of this record class.type()
Returns the value of thetype
record component.version()
Returns the value of theversion
record component.
-
Field Details
-
type
The field for thetype
record component. -
codec
The field for thecodec
record component. -
handler
The field for thehandler
record component. -
protocols
The field for theprotocols
record component. -
flow
The field for theflow
record component. -
version
The field for theversion
record component. -
optional
private final boolean optionalThe field for theoptional
record component.
-
-
Constructor Details
-
PayloadRegistration
public PayloadRegistration(CustomPacketPayload.Type<T> type, StreamCodec<? super RegistryFriendlyByteBuf, T> codec, IPayloadHandler<T> handler, List<ConnectionProtocol> protocols, Optional<PacketFlow> flow, String version, boolean optional) Creates an instance of aPayloadRegistration
record class.- Parameters:
type
- the value for thetype
record componentcodec
- the value for thecodec
record componenthandler
- the value for thehandler
record componentprotocols
- the value for theprotocols
record componentflow
- the value for theflow
record componentversion
- the value for theversion
record componentoptional
- the value for theoptional
record component
-
-
Method Details
-
id
-
matchesFlow
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
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. -
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. -
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
type
Returns the value of thetype
record component.- Returns:
- the value of the
type
record component
-
codec
Returns the value of thecodec
record component.- Returns:
- the value of the
codec
record component
-
handler
Returns the value of thehandler
record component.- Returns:
- the value of the
handler
record component
-
protocols
Returns the value of theprotocols
record component.- Returns:
- the value of the
protocols
record component
-
flow
Returns the value of theflow
record component.- Returns:
- the value of the
flow
record component
-
version
Returns the value of theversion
record component.- Returns:
- the value of the
version
record component
-
optional
public boolean optional()Returns the value of theoptional
record component.- Returns:
- the value of the
optional
record component
-