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
FieldsModifier and TypeFieldDescriptionprivate final StreamCodec<? super RegistryFriendlyByteBuf, T> The field for thecodecrecord component.private final Optional<PacketFlow> The field for theflowrecord component.private final IPayloadHandler<T> The field for thehandlerrecord component.private final booleanThe field for theoptionalrecord component.private final List<ConnectionProtocol> The field for theprotocolsrecord component.private final CustomPacketPayload.Type<T> The field for thetyperecord component.private final StringThe field for theversionrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionPayloadRegistration(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 aPayloadRegistrationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionStreamCodec<? super RegistryFriendlyByteBuf, T> codec()Returns the value of thecodecrecord component.final booleanIndicates whether some other object is "equal to" this one.flow()Returns the value of theflowrecord component.handler()Returns the value of thehandlerrecord component.final inthashCode()Returns a hash code value for this object.id()booleanmatchesFlow(PacketFlow flow) Returns true if the registered flow is compatible with the passed flow.booleanoptional()Returns the value of theoptionalrecord component.Returns the value of theprotocolsrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.version()Returns the value of theversionrecord component.
-
Field Details
-
type
The field for thetyperecord component. -
codec
The field for thecodecrecord component. -
handler
The field for thehandlerrecord component. -
protocols
The field for theprotocolsrecord component. -
flow
The field for theflowrecord component. -
version
The field for theversionrecord component. -
optional
private final boolean optionalThe field for theoptionalrecord 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 aPayloadRegistrationrecord class.- Parameters:
type- the value for thetyperecord componentcodec- the value for thecodecrecord componenthandler- the value for thehandlerrecord componentprotocols- the value for theprotocolsrecord componentflow- the value for theflowrecord componentversion- the value for theversionrecord componentoptional- the value for theoptionalrecord 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 thetyperecord component.- Returns:
- the value of the
typerecord component
-
codec
Returns the value of thecodecrecord component.- Returns:
- the value of the
codecrecord component
-
handler
Returns the value of thehandlerrecord component.- Returns:
- the value of the
handlerrecord component
-
protocols
Returns the value of theprotocolsrecord component.- Returns:
- the value of the
protocolsrecord component
-
flow
Returns the value of theflowrecord component.- Returns:
- the value of the
flowrecord component
-
version
Returns the value of theversionrecord component.- Returns:
- the value of the
versionrecord component
-
optional
public boolean optional()Returns the value of theoptionalrecord component.- Returns:
- the value of the
optionalrecord component
-