I've just run into the second time in two mods where it would be very useful to have an event fired when a potion effect is applied to a living entity (or player). Perhaps something like LivingEvent.PotionAppliedEvent, which has a reference to the potion effect being applied, and can be canceled to prevent the effect from actually applying to the entity/player?
Currently, it seems the only way to do things based on effects is to check the list of effects every tick, which is... certainly not as efficient as it could be. Just a simple hook into the EntityLivingBase.addPotionEffect method would be super useful.
something like this ?? https://gist.github.com/loordgek/136909f694f03c531bbee9da40311fc1
and curePotionEffects event. onFinishedPotionEffect event are also nice to have
Yes, something exactly like that. Except I don't quite get what the potion effect map is? Just an easier way to get the entity's list of current effects than going through the entity itself?
Although I don't think we need a cure potion event and a finished potion event. It can be one PotionEndEvent with a Boolean or enum member describing what caused it to end.
dint see the getter in EntityLivingBase oops
Yep, EntityLivingBase#getActivePotionEffects is how you handle this stuff now, but in the tick event... which is kind of "ew" when you think about how often that event fires compared to how often the player actually gets effects added or removed.
I've also run into this with my mod. The biggest barrier I see to adding an event to EntityLivingBase#addPotionEffect would be handling the difference between a new potion effect and a combined/changed potion effect.
This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!
pr open #4614
This issue has been automatically marked as stale because it has not had activity in a long time. If this issue is still relevant and should remain open, please reply with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___." or "Here's a screenshot of this issue on the latest version"). Thank you for your contributions!
pr still open.
Most helpful comment
something like this ?? https://gist.github.com/loordgek/136909f694f03c531bbee9da40311fc1
and curePotionEffects event. onFinishedPotionEffect event are also nice to have