neoforged / Bus

Event firing and listening framework, based on the event bus concept
GNU Lesser General Public License v2.1
3 stars 8 forks source link

`Event`s should be resettable to a state where they can be posted again #4

Closed Technici4n closed 11 months ago

Technici4n commented 1 year ago

As far as I can tell it's just a matter of adding such a method to Event:

    protected void reset() {
        isCanceled = false;
        result = Result.DEFAULT;
        phase = null;
    }

(event.setCanceled(false).setResult(Result.DEFAULT).setPhase(null) will not work due to setPhase)

Of course, this should come with a nice test too.

Technici4n commented 11 months ago

There is no phase tracking anymore, so .setCanceled(false).setResult(Result.DEFAULT) can be used to reset events.