记录类 ServerPayloadContext
java.lang.Object
java.lang.Record
net.neoforged.neoforge.network.handling.ServerPayloadContext
- 所有已实现的接口:
IPayloadContext
@Internal
public record ServerPayloadContext(ServerCommonPacketListener listener, ResourceLocation payloadId)
extends Record
implements IPayloadContext
-
字段概要
字段修饰符和类型字段说明private final ServerCommonPacketListener
listener
记录组件的字段。private final ResourceLocation
payloadId
记录组件的字段。 -
构造器概要
构造器构造器说明ServerPayloadContext
(ServerCommonPacketListener listener, ResourceLocation payloadId) 创建ServerPayloadContext
记录类的实例。 -
方法概要
修饰符和类型方法说明enqueueWork
(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 boolean
指示某个其他对象是否“等于”此对象。void
Marks aConfigurationTask
as completed.flow()
返回 the flow of the received payload。void
handle
(CustomPacketPayload payload) Handles a payload using the current context.final int
hashCode()
返回此对象的哈希代码值。listener()
返回listener
记录组件的值。返回payloadId
记录组件的值。player()
Retrieves the player relevant to this payload.final String
toString()
返回此记录类的字符串表示形式。从接口继承的方法 net.neoforged.neoforge.network.handling.IPayloadContext
channelHandlerContext, connection, disconnect, handle, protocol, reply
-
字段详细资料
-
listener
listener
记录组件的字段。 -
payloadId
payloadId
记录组件的字段。
-
-
构造器详细资料
-
ServerPayloadContext
创建ServerPayloadContext
记录类的实例。- 参数:
listener
-listener
记录组件的值payloadId
-payloadId
记录组件的值
-
-
方法详细资料
-
handle
从接口复制的说明:IPayloadContext
Handles a payload using the current context.Used to handle sub-payloads if necessary.
- 指定者:
handle
在接口中IPayloadContext
- 参数:
payload
- The payload.
-
enqueueWork
从接口复制的说明:IPayloadContext
For 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(java.util.function.Function<java.lang.Throwable, ? extends T>)
. If you need to catch your own exceptions, use a try/catch block within your task.- 指定者:
enqueueWork
在接口中IPayloadContext
- 参数:
task
- The task to run.
-
enqueueWork
- 指定者:
enqueueWork
在接口中IPayloadContext
- 另请参阅:
-
finishCurrentTask
从接口复制的说明:IPayloadContext
Marks aConfigurationTask
as completed.- 指定者:
finishCurrentTask
在接口中IPayloadContext
- 参数:
type
- The type of task that was completed.
-
flow
从接口复制的说明:IPayloadContext
返回 the flow of the received payload。- 指定者:
flow
在接口中IPayloadContext
- 返回:
- the flow of the received payload
-
player
从接口复制的说明:IPayloadContext
Retrieves the player relevant to this payload. Players are only available in theConnectionProtocol.PLAY
phase.For server-bound payloads, retrieves the sending
ServerPlayer
.For client-bound payloads, retrieves the receiving
LocalPlayer
.- 指定者:
player
在接口中IPayloadContext
-
toString
返回此记录类的字符串表示形式。此表示形式包含类的名称,后跟每个记录组件的名称和值。 -
hashCode
public final int hashCode()返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。 -
equals
指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 此记录类中的所有组件都使用Objects::equals(Object,Object)
进行比较。 -
listener
返回listener
记录组件的值。- 指定者:
listener
在接口中IPayloadContext
- 返回:
listener
记录组件的值
-
payloadId
返回payloadId
记录组件的值。- 返回:
payloadId
记录组件的值
-