I have an eventlistener which applies random potion effects to the player, but it works properly until player is dead. After player respawns function applies only specific and non-instant effects, so i have to restart the game to have the function work properly again.
Here's the code:
EffectInstance effect;
switch(*random n*)
{case *random n*: effect=Potions.*Potion_Name*.getEffects().get(0);}
LivingEntity entity=(LivingEntity) src.getTrueSource();
entity.addPotionEffect(effect) //or entity.addPotionEffect(effect.getEffectInstance()); it doesn't matter.
p.s.
-src.getTrueSource() is always instance of PlayerEntity
-default defined too
-i did Event listener according to forge docs, tried static and everything works till the player is dead.
-Then it works, but improperly (applies some effects with very short duration, about few ticks, maybe 1, so they don't have enough time to trigger).
Don't know why the problem takes place and what else i can do to make this work