Jump to content

[1.7.10] Find Potion ID from Unlocalized Name


AndrewFM

Recommended Posts

I'd like my code to be able to apply potion effects added by other mods, but the IDs of those potion effects aren't necessarily static (certain mods allow you to change the potion IDs via a config file). So instead of doing something like:

 

entityPlayer.addPotionEffect(new PotionEffect(48, 200));

 

I'd prefer to do something like:

 

entityPlayer.addPotionEffect(new PotionEffect("witchery:potion.insane", 200));

 

But I'm not sure how to get the corresponding integer ids from the unlocalized names of the potions.

Link to comment
Share on other sites

Iterate through

Potion.potionTypes

until you find a

Potion

that returns the specified name from

Potion#getName

. You'll probably want to do this once at startup rather than every time you apply the effect.

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.

Link to comment
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.
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.