Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.event

Generated

This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.

TypeKindDescription
EventKeyclassIdentifies one event and the listener interface it calls.
EventPriorityenumWhen a listener runs relative to the other listeners of the same event.
EventRegistryinterfaceRegisters event listeners for the calling mod.
EventResultenumThe answer of a listener in a decision event, an event whose listeners may cancel or force what the game is about to do (for example BlockEvents.BREAK).

EventKey​

class · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public final class EventKey<L>

Identifies one event and the listener interface it calls. Keys are compared by identity; each event has exactly one key constant, e.g. ServerEvents.STARTED.

of(String, Class<L>)​

public static <L> EventKey<L> of(String id, Class<L> listenerType)

Since 0.1.0-alpha.4 or earlier

Creates a key; id is namespace:path and only used for diagnostics.

ParameterTypeDescription
idString—
listenerTypeClass<L>—

Returns EventKey<L>

id()​

public String id()

Since 0.1.0-alpha.4 or earlier

Diagnostic ID, e.g. poly:server/started.

Returns String

listenerType()​

public Class<L> listenerType()

Since 0.1.0-alpha.4 or earlier

The listener interface.

Returns Class<L>

EventPriority​

enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public enum EventPriority

When a listener runs relative to the other listeners of the same event. Listeners run from HIGHEST to LOWEST; listeners with the same priority run in registration order (and therefore, for listeners registered from entrypoints, in mod load order).

Use a higher priority to decide first in a decision event (for example a protection mod that refuses block breaking in claimed areas), a lower one to see what the others left alone. The levels have the same names and order as NeoForge's EventPriority; Fabric event phases map onto them (the default phase is NORMAL).

ConstantDescription
HIGHESTRuns first.
HIGHRuns before NORMAL.
NORMALThe default for EventRegistry.register(EventKey, Object).
LOWRuns after NORMAL.
LOWESTRuns last.

EventRegistry​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface EventRegistry

Registers event listeners for the calling mod. Obtained from ModContext.events().

register(EventKey<L>, L)​

default <L> void register(EventKey<L> event, L listener)

Since 0.1.0-alpha.4 or earlier

Registers listener for event with EventPriority.NORMAL.

ParameterTypeDescription
eventEventKey<L>—
listenerL—

register(EventKey<L>, EventPriority, L)​

<L> void register(EventKey<L> event, EventPriority priority, L listener)

Since 0.1.0-alpha.4 or earlier

Registers listener for event. Listeners run from EventPriority.HIGHEST to EventPriority.LOWEST; listeners with the same priority run in registration order. In decision events the first deciding listener ends the event (see EventResult).

Thread: any; registration is thread-safe. When: at any time, usually in an entrypoint; a listener registered while the event is being fired runs from the next firing on.

Failure: a listener that throws is reported with the mod ID and disabled (POLY-EVENT-001); other listeners and the game keep running.

ParameterTypeDescription
eventEventKey<L>—
priorityEventPriority—
listenerL—

Throws IllegalArgumentException — when listener does not implement the event's listener type

Throws NullPointerException — when an argument is null

EventResult​

enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public enum EventResult

The answer of a listener in a decision event, an event whose listeners may cancel or force what the game is about to do (for example BlockEvents.BREAK).

Convention (the same for every decision event): listeners run in EventPriority order; the first listener that returns ALLOW or DENY decides, and the listeners after it are not called. When every listener returns PASS, the game does what it would have done without Poly Mod Loader. A listener that throws counts as PASS and is disabled (POLY-EVENT-001); a listener that returns null is treated the same way (POLY-EVENT-003).

Interaction events use dev.polymodloader.api.world.InteractionResult instead, with the same rule: PASS lets the next listener run, anything else decides.

ConstantDescription
PASSNo opinion: the next listener runs, and without a decision the game goes on as usual.
ALLOWLets the action happen and skips the remaining listeners (the game's own checks still apply).
DENYCancels the action and skips the remaining listeners.

isDecided()​

public boolean isDecided()

Since 0.1.0-alpha.4 or earlier

Whether this result decides the event, i.e. is not PASS.

Returns boolean

Buy me a coffee