ServerToClientPacketDefinition

class ServerToClientPacketDefinition<T : Any>(id: ResourceLocation, binaryFormat: BinaryFormat, deserializer: KSerializer<T>) : AbstractPacketDefinition<T, ClientPacketContext> (source)

See s2cPacket function, which constructs this packet definition class.

Constructors

Link copied to clipboard
constructor(id: ResourceLocation, binaryFormat: BinaryFormat, deserializer: KSerializer<T>)

Properties

Link copied to clipboard
val binaryFormat: BinaryFormat
Link copied to clipboard
val id: ResourceLocation
Link copied to clipboard
val streamCodec: StreamCodec<FriendlyByteBuf, SilkPacketPayload>
Link copied to clipboard
val type: CustomPacketPayload.Type<SilkPacketPayload>

Functions

Link copied to clipboard
fun receiveOnClient(receiver: suspend (packet: T, context: ClientPacketContext) -> Unit)

Executes the given receiver as a callback when this packet is received on the client-side.

Link copied to clipboard
fun send(value: T, player: ServerPlayer)

Sends the given value to the given player. This will result in the serialization of the given value.

Link copied to clipboard
fun sendToAll(value: T)

Sends the given value to all players on the server. This will result the serialization of the given value.