PacketReceiveEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct PacketReceiveEvent : IEventA 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.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Constructor |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”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 |
Properties
Section titled “Properties”| 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. |
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Connection
Section titled “Connection”public ulong Connection { get; }Connection id.
PacketId
Section titled “PacketId”public int PacketId { get; }Packet id.
Payload
Section titled “Payload”public NativeBytes Payload { get; }Packet body (borrowed).
Player
Section titled “Player”public Player Player { get; }The player entity (none before play).
public byte State { get; }Connection state.
CatalogueId
Section titled “CatalogueId”public static ushort CatalogueId { get; }Catalogue id (stable ABI).
IsCancellable
Section titled “IsCancellable”public static bool IsCancellable { get; }Whether handlers can cancel the event.
public static string Key { get; }Registry key of the event.
See also
Section titled “See also”IEvent · NativeBytes · Player