Skip to content

PacketEvent<T>

Namespace Mc.Scripting · Kind class (sealed)

public sealed class PacketEvent<T> where T : PacketBase

One packet handed to a handler. In intercept mode the handler may change PacketEvent.Packet and call PacketEvent.Cancel.

Member Description
bool Cancelled { get; } True once a handler cancelled the packet.
T Packet { get; } The packet.
Player Player { get; } The player the packet is from (serverbound) or to (clientbound).
public bool Cancelled { get; }

True once a handler cancelled the packet.

public T Packet { get; }

The packet. Changing its fields changes what goes on (the engine validates the new values like any other).

public Player Player { get; }

The player the packet is from (serverbound) or to (clientbound).

Member Description
void Cancel() Stops the packet: a serverbound packet’s handler does not run, a clientbound packet is not sent.
public void Cancel()

Stops the packet: a serverbound packet’s handler does not run, a clientbound packet is not sent. Only in intercept mode; an observer’s cancel is ignored.

Player