Record Class PlayRegistration<T extends CustomPacketPayload>
java.lang.Object
java.lang.Record
net.neoforged.neoforge.network.registration.PlayRegistration<T>
- Type Parameters:
T
- The type of the payload- Record Components:
reader
- The reader for the payloadhandler
- The handler for the payloadversion
- The version of the payloadflow
- The flow of the payloadoptional
- Whether the payload is optional
- All Implemented Interfaces:
Function<FriendlyByteBuf,
,CustomPacketPayload> FriendlyByteBuf.Reader<CustomPacketPayload>
,IPlayPayloadHandler<CustomPacketPayload>
@Internal
public record PlayRegistration<T extends CustomPacketPayload>(FriendlyByteBuf.Reader<T extends CustomPacketPayload> reader, IPlayPayloadHandler<T extends CustomPacketPayload> handler, Optional<String> version, Optional<PacketFlow> flow, boolean optional)
extends Record
implements IPlayPayloadHandler<CustomPacketPayload>, FriendlyByteBuf.Reader<CustomPacketPayload>
A record that holds the information needed to describe a registered play payload, its reader and handler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Optional<PacketFlow>
The field for theflow
record component.private final IPlayPayloadHandler<T>
The field for thehandler
record component.private final boolean
The field for theoptional
record component.private final FriendlyByteBuf.Reader<T>
The field for thereader
record component.The field for theversion
record component. -
Constructor Summary
ConstructorsConstructorDescriptionPlayRegistration
(FriendlyByteBuf.Reader<T> reader, IPlayPayloadHandler<T> handler, Optional<String> version, Optional<PacketFlow> flow, boolean optional) Creates an instance of aPlayRegistration
record class. -
Method Summary
Modifier and TypeMethodDescriptionapply
(FriendlyByteBuf buffer) final boolean
Indicates whether some other object is "equal to" this one.flow()
Returns the value of theflow
record component.void
handle
(CustomPacketPayload payload, PlayPayloadContext context) Invoked to handle the given payload in the given context.handler()
Returns the value of thehandler
record component.final int
hashCode()
Returns a hash code value for this object.boolean
optional()
Returns the value of theoptional
record component.reader()
Returns the value of thereader
record component.final String
toString()
Returns a string representation of this record class.version()
Returns the value of theversion
record component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraft.network.FriendlyByteBuf.Reader
asOptional
-
Field Details
-
Constructor Details
-
PlayRegistration
public PlayRegistration(FriendlyByteBuf.Reader<T> reader, IPlayPayloadHandler<T> handler, Optional<String> version, Optional<PacketFlow> flow, boolean optional) Creates an instance of aPlayRegistration
record class.
-
-
Method Details
-
handle
Description copied from interface:IPlayPayloadHandler
Invoked to handle the given payload in the given context.- Specified by:
handle
in interfaceIPlayPayloadHandler<T extends CustomPacketPayload>
- Parameters:
payload
- The payload.context
- The context.
-
apply
- Specified by:
apply
in interfaceFunction<FriendlyByteBuf,
CustomPacketPayload>
-
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 '=='. -
reader
Returns the value of thereader
record component.- Returns:
- the value of the
reader
record component
-
handler
Returns the value of thehandler
record component.- Returns:
- the value of the
handler
record component
-
version
Returns the value of theversion
record component.- Returns:
- the value of the
version
record component
-
flow
Returns the value of theflow
record component.- Returns:
- the value of the
flow
record component
-
optional
public boolean optional()Returns the value of theoptional
record component.- Returns:
- the value of the
optional
record component
-