Jump to content

[1.12.2] How to check for when a player gets a potion effect, and when it wears off


Daring Do

Recommended Posts

Anyone know of any methods or events to test for when a player gets a potion effect, and when that effect wears off? I've tried onNewPotionEffect, but it being protected makes it impossible for me to use.

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Link to comment
Share on other sites

5 hours ago, Daring Do said:

I've tried onNewPotionEffect

That method applies the attribute modifiers of a given potion to the entity.

 

5 hours ago, Daring Do said:

but it being protected makes it impossible for me to use

No it doesn't. Reflection is a thing.

 

5 hours ago, Daring Do said:

Anyone know of any methods or events to test for when a player gets a potion effect, and when that effect wears off?

As far as I know forge has no relevant hooks so your best bet is to store a collection of all currently active potion effects in a capability attached to the entity, then each tick compare your collection to the entity's. If some entries in the entity's collection are missing but are present in yours then the potion effect expired. If there are entries in the entity's collection but not in yours then the potion was added. After you are done update your collection to be even with the entity's.

Link to comment
Share on other sites

7 hours ago, V0idWa1k3r said:

No it doesn't. Reflection is a thing.

The bit about reflection is what I tried. And, as far as I could tell, I couldn't set it up so that I could use it to send a new packet. I'm working with networking currently, and was hoping I could find a better method of sending the packets than what I'm doing now.

 

I can try the capability approach, but I know jackshit about them.

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

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.



×
×
  • Create New...

Important Information

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