Reference

EymistakenHudEventBus

Lets addons react to things happening inside the HUD.

public final class EymistakenHudEventBus, in com.eymistaken.simplecps.api, since 1.2.0. There is one instance, handed to EymistakenHudPlugin.registerEvents().

Members

static EymistakenHudEventBus getInstance()since 1.2.0

The one bus.

<T> void subscribe(Class<T> type, Consumer<? super T> handler)since 1.2.0

Listens for one event type. Safe to call at any point after client init. A null type or handler is ignored.

<T> void emit(T event)since 1.2.0

Delivers an event to every subscriber of its exact class. A null event is ignored.

How dispatch works

Exact classSubscribing to a supertype does not receive subclasses.
Client threadHandlers run on the client thread, inline with whatever caused the event, so keep them short.
FailuresA handler that throws is logged and skipped. It never takes the rest of the mod down with it.
Subscribing mid-dispatchSafe. The handler list is copy-on-write, so a handler that subscribes while an event is being delivered cannot break the loop that is running.