Skip to content

Events

Section notes in abi.h

the core slots, present since ABI v1

Slots

subscribe_event

C
1
2
3
4
5
6
7
PierListenerHandle (*subscribe_event)(
    PierModHandle mod,
    PierStr event_id,
    int32_t priority,
    PierEventCb cb,
    void* user
);

Subscribe to a LeviLamina event by id (server thread only).

Text Only
1
2
3
4
5
event_id : full id, e.g. "ll::event::PlayerChatEvent". If no exact
           match exists, the loader falls back to a unique suffix
           match ("PlayerChatEvent" works if unambiguous).
priority : 0..4 (Highest..Lowest), 2 = Normal
           (mirrors ll::event::EventPriority).

Returns NULL on failure (unknown/ambiguous id).

  • Call: api->subscribe_event(mod, event_id, priority, cb, user)
  • Parameters:
    • mod : PierModHandle
    • event_id : PierStr
    • priority : int32_t
    • cb : PierEventCb
    • user : void*
  • Return type: PierListenerHandle
  • Section of abi.h: the core slots, present since ABI v1
  • Position in the table: slot 4, counting from 0
  • Callers in each binding:

unsubscribe_event

C
bool (*unsubscribe_event)(PierModHandle mod, PierListenerHandle listener);

Remove a listener previously returned by subscribe_event. Server thread only.

  • Call: api->unsubscribe_event(mod, listener)
  • Parameters:
    • mod : PierModHandle
    • listener : PierListenerHandle
  • Return type: bool
  • Section of abi.h: the core slots, present since ABI v1
  • Position in the table: slot 5, counting from 0
  • Callers in each binding:

list_events

C
void (*list_events)(void* ctx, PierStrSink sink);

Enumerate all currently registered event ids. Server thread only.

Types

PierListenerHandle

C
typedef void* PierListenerHandle;

Opaque handle to an event listener.

PierEventCb

C
1
2
3
4
5
6
7
typedef void (*PierEventCb)(
    void* user,
    PierStr event_id,
    PierStr snbt,
    void* write_ctx,
    PierStrSink write_back
);

Event callback.

Text Only
1
2
3
4
5
6
7
8
event_id : the full event id this listener fired for.
snbt     : event data serialized as SNBT (CompoundTag). For cancellable
           events it contains a `cancelled` byte field.
write_ctx / write_back : to mutate the event (e.g. cancel it, edit the
           chat message), call write_back(write_ctx, new_snbt) with the
           modified SNBT before returning. The loader deserializes it
           back into the event. Calling it zero times leaves the event
           untouched; the last call wins.