#1.21.5 detect when player gets poison/blindness effect and remove those effects

2 messages · Page 1 of 1 (latest)

smoky hawk
#

i know where to start whit this

create a custom flower crop i can do that
later want this flower to be edible by the player that's feasible

flower must remove the poison and blind effect from the player
i dont have idea on how to achieve that i need help whit this part

and also want this flower to grant protection against poison/blindness for a short amount of time, also dont know how
maybe

  • an event triggered when player gets some status effect on him ?
  • an costume entity watching on the player like the honey fairy from adventure island but invisible ?
#

i got this

public void remove_poison(LivingEntity le){
   //System.out.println("remove_poison");
    Collection<StatusEffectInstance> effects = le.getStatusEffects();//  .getActiveEffects();
    Iterator<StatusEffectInstance> iterator = effects.iterator();
    for( StatusEffectInstance effectinstance : effects ){
       System.out.println(effectinstance.toString());

        if( POISON == effectinstance )
        {
            le.removeStatusEffect(effectinstance.getEffectType());
        }
    }
}

looks nice don't works
at least it tells poison effect and remaining time

[19:42:54] [Server thread/INFO] (Minecraft) [STDOUT]: effect.minecraft.poison, Duration: 1754
[19:42:54] [Render thread/INFO] (Minecraft) [STDOUT]: effect.minecraft.poison, Duration: 1753
[19:42:54] [Server thread/INFO] (Minecraft) [STDOUT]: effect.minecraft.poison, Duration: 1749
[19:42:54] [Render thread/INFO] (Minecraft) [STDOUT]: effect.minecraft.poison, Duration: 1748
[19:42:54] [Server thread/INFO] (Minecraft) [STDOUT]: effect.minecraft.poison, Duration: 1744
[19:42:54] [Render thread/INFO] (Minecraft) [STDOUT]: effect.minecraft.poison, Duration: 1743
[19:42:55] [Server thread/INFO] (Minecraft) [STDOUT]: effect.minecraft.poison, Duration: 1739