ClientToServerPacketDefinition

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

See c2sPacket 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 receiveOnServer(receiver: suspend (packet: T, context: ServerPacketContext) -> Unit)

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

Link copied to clipboard
fun send(value: T)

Sends the given value as a packet to the server.