Skip to content

IEvent

Namespace Mc.Scripting · Kind interface

public interface IEvent

An event type. Catalogue events are ref structs: a handler gets the event by reference and can neither store it nor capture it in a closure or an async method, so the borrowed native data it carries (strings, byte buffers) cannot outlive the dispatch. Plugin-defined events are ordinary blittable structs that start with an EventHeader field (or ref structs of the same layout).

Catalogue events are generated from src/scripting/events.json. Plugins can declare their own events: implement IEvent.Key (e.g. “myplugin:thing”) and leave IEvent.CatalogueId at 0; an id is assigned at runtime.

A custom event

public struct HomeSetEvent : IEvent
{
public EventHeader Header; // must come first
public Entity Player;
public BlockPos Position;
public static string Key => "homes:set";
public static bool IsCancellable => true;
}
// fire it from your plugin
var ev = new HomeSetEvent { Player = p, Position = pos };
if (Events.Fire(ref ev)) { /* nobody cancelled */ }
Member Description
static virtual ushort CatalogueId { get; } Catalogue id for built-in events, 0 for plugin-defined events.
static virtual bool IsCancellable { get; } Whether handlers can cancel the event.
static abstract string Key { get; } Registry key (“plugin:name” for plugin events).
static virtual ushort CatalogueId { get; }

Catalogue id for built-in events, 0 for plugin-defined events.

static virtual bool IsCancellable { get; }

Whether handlers can cancel the event.

static abstract string Key { get; }

Registry key (“plugin:name” for plugin events).