Event System
Event annotation
Section titled “Event annotation”Use @SSEvent on a method to register it against a Fabric callback interface.
public class MyEvents { @SSEvent(ServerLifecycleEvents.ServerStarting.class) public static void onServerStart(MinecraftServer server) { // ... }}@SSEvent accepts:
value: the Fabric listener interface to bindpriority: lower numbers run first
What EventRegistrar does
Section titled “What EventRegistrar does”The registrar:
- collects methods annotated with
@SSEvent - sorts them by
priority - supports both static and instance methods
- skips
@SSECDebugmethods outside the Fabric development environment - creates a proxy that implements the target callback interface
- registers that proxy into the matching Fabric
Event<?>
Event lookup strategy
Section titled “Event lookup strategy”When EventRegistrar resolves an event target, it looks for:
- a static
Event<?>field on the listener class itself - a generic
Event<?>field in the enclosing class whose type parameter matches the listener - a fallback field-name match in the enclosing class
That mirrors common Fabric event declaration patterns and keeps the annotation side terse.
Static vs instance registration
Section titled “Static vs instance registration”There are two main registration flows:
registerStatic(Class<?>)for static-only handlersregister(Object)for mixed static and instance methods on a target object
If you do not need instance state, static handlers are simpler and avoid lifecycle questions.
Debug-only listeners
Section titled “Debug-only listeners”@SSECDebug can be layered on an event method to keep it active only in development environments.
That is useful for tracing, logging-heavy listeners, or temporary debug hooks that should never ship on production servers.