Skip to content

PacketReceiveEvent

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

public ref struct PacketReceiveEvent : IEvent

A decoded-frame packet arrived (payload excludes the packet id). Cancel to drop it.

Id 40
Key mc:packet_receive
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 PacketReceiveEvent(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