Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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."

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.

  • Author
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."

  • Author

Hmm... any ideas on how to use the PotionApplicableEvent?

Gne9eza.png

 

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

  • Author

Never mind, I've figured it out. I should read more.

Gne9eza.png

 

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.