How to check when a LivingEntity is dead

Discussion in 'Plugin Development' started by tips48, Oct 9, 2011.

Thread Status:
Not open for further replies.
  1. So, basically. I have a PlayerInteract Event.
    This code damages the entity
    Code:java
    1.  
    2. LivingEntity e = getLookingAt(p);
    3. e.damage(g.getBodyDamage(), p);
    4.  

    (It all works, that isn't the problem)
    I now need to check if e is dead. First, I used e.isDead(), but that didn't work. Then I used e.getHealth() <= 0. That works, but the problem is while the entity is going through its death animation it still returns true, thus leading to it being true more than once.
     
  2. Offline

    user_43347

    You could just call the onEntityDamage event, get the attacker from the livingentity. Try using e.getHealth() < 0 because when it's equal, the entity can still be living.

    Just a suggestion, someone else probably has a more full proof way.
    P.S. Get on IRC :p
     
Thread Status:
Not open for further replies.

Share This Page