Skip to content

Commit

Permalink
Add IEventBus#fire to return the posted event object (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaintNinja authored Jun 21, 2024
1 parent e2a19cb commit 6d0589d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/net/minecraftforge/eventbus/api/IEventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ public interface IEventBus {
*/
boolean post(Event event, IEventBusInvokeDispatcher wrapper);

/**
* Submit the event for dispatch to appropriate listeners and return the (possibly mutated) event
*
* @param event The event to dispatch to listeners
* @return The event object that was dispatched
*/
default <T extends Event> T fire(T event) {
post(event);
return event;
}

default <T extends Event> T fire(T event, IEventBusInvokeDispatcher wrapper) {
post(event, wrapper);
return event;
}

/**
* Shuts down this event bus.
*
Expand Down

0 comments on commit 6d0589d

Please sign in to comment.