Daring Do Posted December 1, 2018 Posted December 1, 2018 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. Quote "Be patient with me, because I'm an absolute moron half the time."
V0idWa1k3r Posted December 1, 2018 Posted December 1, 2018 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. Quote
MCenderdragon Posted December 1, 2018 Posted December 1, 2018 You basicaly want this Pull Request getting accepted: https://github.com/MinecraftForge/MinecraftForge/pull/4614. Quote catch(Exception e) { } Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).
Daring Do Posted December 1, 2018 Author Posted December 1, 2018 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. Quote "Be patient with me, because I'm an absolute moron half the time."
Daring Do Posted December 1, 2018 Author Posted December 1, 2018 45 minutes ago, MCenderdragon said: You basicaly want this Pull Request getting accepted: https://github.com/MinecraftForge/MinecraftForge/pull/4614. Ah. Well, hopefully it happens. Quote "Be patient with me, because I'm an absolute moron half the time."
loordgek Posted December 2, 2018 Posted December 2, 2018 the pr is in now https://github.com/MinecraftForge/MinecraftForge/commit/2a5268c6993f2de7612789bfac2b674d04c87e89 Quote
Daring Do Posted December 2, 2018 Author Posted December 2, 2018 2 hours ago, loordgek said: the pr is in now https://github.com/MinecraftForge/MinecraftForge/commit/2a5268c6993f2de7612789bfac2b674d04c87e89 \o/ Quote "Be patient with me, because I'm an absolute moron half the time."
Daring Do Posted December 2, 2018 Author Posted December 2, 2018 Hmm... any ideas on how to use the PotionApplicableEvent? Quote "Be patient with me, because I'm an absolute moron half the time."
Daring Do Posted December 2, 2018 Author Posted December 2, 2018 Never mind, I've figured it out. I should read more. Quote "Be patient with me, because I'm an absolute moron half the time."
Recommended Posts
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.