Skip to content

PacketSendEvent

Namespace Mc.Scripting.Events · Kind struct (ref)

public ref struct PacketSendEvent : IEvent

RESERVED: not fired yet (the per-connection send path encodes shared frames). A packet is about to be sent to one connection.

Id 41
Key mc:packet_send
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Connection ulong no (readonly) Connection id.
Player player no (readonly) The player entity (none before play).
State byte no (readonly) Connection state.
PacketId int no (readonly) Packet id.
Payload NativeBytes no (readonly) Packet body (borrowed).

Set e.Cancelled = true in a handler to cancel it; lower-priority handlers are skipped unless they subscribed with receiveCancelled: true.

Member Description
Constructor Creates the event (for firing it from a plugin; native code builds its own).
public PacketSendEvent(ulong connection, Player player, byte state, int packetId, NativeBytes payload)

Creates the event (for firing it from a plugin; native code builds its own). Signature of API 1.0.

Parameters

Name Type Description
connection ulong
player Player
state byte
packetId int
payload NativeBytes
Member Description
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
ulong Connection { get; } Connection id.
int PacketId { get; } Packet id.
NativeBytes Payload { get; } Packet body (borrowed).
Player Player { get; } The player entity (none before play).
byte State { get; } Connection state.
static ushort CatalogueId { get; } Catalogue id (stable ABI).
static bool IsCancellable { get; } Whether handlers can cancel the event.
static string Key { get; } Registry key of the event.
public bool Cancelled { get; set; }

Cancelling stops lower-priority handlers (unless they opt in) and the action itself.

public ulong Connection { get; }

Connection id.

public int PacketId { get; }

Packet id.

public NativeBytes Payload { get; }

Packet body (borrowed).

public Player Player { get; }

The player entity (none before play).

public byte State { get; }

Connection state.

public static ushort CatalogueId { get; }

Catalogue id (stable ABI).

public static bool IsCancellable { get; }

Whether handlers can cancel the event.

public static string Key { get; }

Registry key of the event.

IEvent · NativeBytes · Player