Fabric API

Fabric API

106M Downloads

Event Listener Priority

Darkhax opened this issue ยท 2 comments

commented

For events, it is useful to have a priority system. The general idea is that listeners can tell Fabric they want to be invoked earlier or later than the average listener. This is mainly useful for things like CraftTweaker or GameStage type mods where you need to prevent things from happening, or modify the initial context of the event.

The Forge Approach - In this approach there are 5 levels, highest, high, normal, low, lowest. The higher the priority the sooner the listener is called. This system is not 100% perfect, but it does work for the vast majority of cases and has been used in Forge for a very long time without any major substantial complaints.

Other Approaches - I don't know the specifics. Will update as people weigh in on the discussion.

commented

Why use enum priorities when you can use integer priorities

commented

The last 2 years have shown that multiple callbacks each occupying a specific part of the process works fine. Though the structure of these events needs to be worked on and is discussed in #1121

Closing since the decision seems to have been made.