Record Class ClientPayloadContext
java.lang.Object
java.lang.Record
net.neoforged.neoforge.client.network.handling.ClientPayloadContext
- All Implemented Interfaces:
IPayloadContext
@Internal
public record ClientPayloadContext(ClientCommonPacketListener listener, Identifier payloadId)
extends Record
implements IPayloadContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClientCommonPacketListenerThe field for thelistenerrecord component.private final IdentifierThe field for thepayloadIdrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionClientPayloadContext(ClientCommonPacketListener listener, Identifier payloadId) Creates an instance of aClientPayloadContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionenqueueWork(Runnable task) For handlers running on the network thread, submits the given task to be run on the main thread of the game.<T> CompletableFuture<T> enqueueWork(Supplier<T> task) final booleanIndicates whether some other object is "equal to" this one.voidMarks aConfigurationTaskas completed.flow()Returns the flow of the received payload.voidhandle(CustomPacketPayload payload) Handles a payload using the current context.final inthashCode()Returns a hash code value for this object.listener()Returns the value of thelistenerrecord component.Returns the value of thepayloadIdrecord component.player()Retrieves the player relevant to this payload.final StringtoString()Returns a string representation of this record class.Methods inherited from interface IPayloadContext
channelHandlerContext, connection, disconnect, handle, protocol, reply
-
Field Details
-
listener
The field for thelistenerrecord component. -
payloadId
The field for thepayloadIdrecord component.
-
-
Constructor Details
-
ClientPayloadContext
Creates an instance of aClientPayloadContextrecord class.- Parameters:
listener- the value for thelistenerrecord componentpayloadId- the value for thepayloadIdrecord component
-
-
Method Details
-
handle
Description copied from interface:IPayloadContextHandles a payload using the current context.Used to handle sub-payloads if necessary.
- Specified by:
handlein interfaceIPayloadContext- Parameters:
payload- The payload.
-
enqueueWork
Description copied from interface:IPayloadContextFor handlers running on the network thread, submits the given task to be run on the main thread of the game.For handlers running on the main thread, immediately executes the task.
On the network thread, the future will be automatically guarded against exceptions using
CompletableFuture.exceptionally(Function). If you need to catch your own exceptions, use a try/catch block within your task.- Specified by:
enqueueWorkin interfaceIPayloadContext- Parameters:
task- The task to run.
-
enqueueWork
- Specified by:
enqueueWorkin interfaceIPayloadContext- See Also:
-
finishCurrentTask
Description copied from interface:IPayloadContextMarks aConfigurationTaskas completed.- Specified by:
finishCurrentTaskin interfaceIPayloadContext- Parameters:
type- The type of task that was completed.
-
flow
Description copied from interface:IPayloadContextReturns the flow of the received payload.- Specified by:
flowin interfaceIPayloadContext- Returns:
- the flow of the received payload
-
player
Description copied from interface:IPayloadContextRetrieves the player relevant to this payload. Players are only available in theConnectionProtocol.PLAYphase.For server-bound payloads, retrieves the sending
ServerPlayer.For client-bound payloads, retrieves the receiving
LocalPlayer.- Specified by:
playerin interfaceIPayloadContext
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
listener
Returns the value of thelistenerrecord component.- Specified by:
listenerin interfaceIPayloadContext- Returns:
- the value of the
listenerrecord component
-
payloadId
Returns the value of thepayloadIdrecord component.- Returns:
- the value of the
payloadIdrecord component
-