This is a near-complete rework of the event system, keeping its original goals but rethinking the implementation.
-
Events are now generic, so
ConsumerEvent
becomesEvent<Consumer>
, andRunnableEvent
becomesEvent<Runnable>
. -
This allows a great proliferation of event types using just the
Event
class and various functional interfaces. Factory methods for many of these possibilities are now available inEventFactories
andChainEventFactories
-
EventFactory<T>
objects can make instances ofEvent<T>
. Many instances of these are also provided.
If you're familiar with Fabric events, the new system should feel very familiar.
Each Event has an invoker object with the same type as event-handlers. This invoker can be used to fire events and collect the event's result. Regular events use reducer functions to turn the set of event responses into a single result that the invoker returns. Chain events hand the result of each handler to the next handler, so the invoker's return value is the output of the last handler.