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 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, 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 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, 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.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
-
Constructor Details
-
PayloadRegistration
public PayloadRegistration(CustomPacketPayload.Type<T> type, StreamCodec<? super RegistryFriendlyByteBuf, T> codec, 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 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
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
type
-
codec
-
protocols
-
flow
-
version
-
optional
-