Jump to content

Recommended Posts

Posted (edited)
3 minutes ago, Alexiy said:

I guess it's for sorting the event listeners - those who have higher priority will be notified of event before those having the lower.

Yes, but which gets executed first if the same two events have priority set to NORMAL?

Edited by Differentiation
Posted (edited)
39 minutes ago, Differentiation said:

Yes, but which gets executed first if the same two events have priority set to NORMAL?

 

Event handlers with the same priority are called in the order that they were registered in. This isn't documented, so it's probably best to consider it an implementation detail that shouldn't be relied upon.

Edited by Choonster
  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I discuss priority a bit in my event handling tutorial: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

 

I believe if they have same priority they will fire in same order as the mods are loaded, but I haven't tested that.

 

The idea of priority is also related to the cancellation of the events because the first mod that cancels the event I believe will prevent all later mods from getting the event. However, you can actually undo that by setting receive cancelled to true...

 

So it really depends on what you're doing in the event. I personally tend to be "selfish" and set the priority to HIGHEST to make sure I get the event, but that is when I'm not doing anything that is likely to interfere with other mods and also not if I'm going to cancel it. If I'm going to cancel it, I'll go last but also set receive cancelled to true, since I believe most mods are intending to cancel the vanilla behavior when they cancel the event.

 

In the end, events are definitely a place where mod conflicts can occur and if you have multiple mods and your event isn't firing like it normally does then you need to look at the priority and cancellation policies of your event and possibly work with the other mod's author to make them play nicely together.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.