Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • "Configurable" event priority - is this OK?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
CosmicDan

"Configurable" event priority - is this OK?

By CosmicDan, April 1, 2018 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

CosmicDan    5

CosmicDan

CosmicDan    5

  • Tree Puncher
  • CosmicDan
  • Members
  • 5
  • 42 posts
Posted April 1, 2018 (edited)

Howdy,

 

Is this alright or is there a better way?

 

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onSomeEventWithResultLate(SomeEventWithResult event) {
  if (ModConfig.COMPATIBILITY.runLatest) {
    // do stuff as late as possible so hopefully our result is the one that counts
  }
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onSomeEventWithResultEarly(SomeEventWithResult event) {
  if (!ModConfig.COMPATIBILITY.runLatest) {
    // do stuff as soon as possible to let other mod events override it if they want
  }
}

 

Obviously the idea is to let the user decide whether they want this aspect of a mod to be more important to less important than other mods.

 

I may also have logic in the LOWEST priority to react differently depending on an existing result, if any, but that's neither here nor there.

Edited April 1, 2018 by CosmicDan
Method names
  • Quote

CosmicDan.com

Windows software, Android hacking, and other curios

Share this post


Link to post
Share on other sites

jabelar    593

jabelar

jabelar    593

  • Reality Controller
  • jabelar
  • Members
  • 593
  • 3266 posts
Posted April 3, 2018 (edited)

Yeah, I think that should work except that if other mods set their priority to highest then you you're not guaranteed to have yours go before theirs (I assume the order is based on mod loading or modID alphabetical) and if other mods set their priority to lowest then you're not guaranteed to have yours go after thiers. In fact, one or the other will not fully work because if you're first in order for the highest then you'll be first in order for the lowest, and vice versa. But at least you can say you tried. And it should work for mods where they leave the priority at default (normal).

Edited April 3, 2018 by jabelar
  • Thanks 1
  • Quote

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • QWERTY 52 38
      [1.16.4]NullPointerException when using registered custom features

      By QWERTY 52 38 · Posted 5 minutes ago

      Generate feature mcbbswiki:feature_lucky_block in Mcbbs Wiki Normal Biome
    • dotifo7120
      Check packet sender

      By dotifo7120 · Posted 6 minutes ago

      Thank you a lot!
    • diesieben07
      [1.16.4]NullPointerException when using registered custom features

      By diesieben07 · Posted 9 minutes ago

      Do what?
    • diesieben07
      Check packet sender

      By diesieben07 · Posted 9 minutes ago

      Considering you are using Spigot on the server, I assume your mod is on the client. The client will never receive packets that are sent "by a player". You have two packet directions, client to server and server to client. For client to server, the server will have a "sending player" for the packet (the player whose client sent the packet). For server to client (your case) this obviously does not make sense, as the sender of the packet is the server and not some other player.
    • dotifo7120
      Check packet sender

      By dotifo7120 · Posted 15 minutes ago

      I'm sending packets to my mod using sendPluginMessage, but how I can check in the mod that a package was sent from the plugin and not by a player? getSender() in Supplier<NetworkEvent.Context> doesn't seem helpful
  • Topics

    • QWERTY 52 38
      6
      [1.16.4]NullPointerException when using registered custom features

      By QWERTY 52 38
      Started 2 hours ago

    • dotifo7120
      2
      Check packet sender

      By dotifo7120
      Started 15 minutes ago

    • GenElectrovise
      5
      [ForgeGradle] Publish project to GitHub Packages

      By GenElectrovise
      Started Friday at 09:04 PM

    • DBLouis
      13
      [SOLVED] [1.10] ModelResourceLocation and model loading errors

      By DBLouis
      Started August 19, 2016

    • myrqn
      5
      Forge Not Opening

      By myrqn
      Started 5 hours ago

  • Who's Online (See full list)

    • dotifo7120
    • diesieben07
    • QWERTY 52 38
    • Reflector_10
    • Detty_TV22
    • S-Spirit
    • CookieLukas
    • monkeysHK
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • "Configurable" event priority - is this OK?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community