1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to check for an entity dying

Discussion in 'Development' started by Indexfire, Feb 18, 2017.

  1. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    Im trying to make a plugin for fun where if a Special Zombie named "Life" died the game would kill the player. But there isnt any way i know of to check for a mob dying. How would i do that?
     
    yBriisMC likes this.
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Pre-Death:
    PHP:
    public function onDamage(EntityDamageEvent $event){
        if((
    $zombie $event->getEntity()) instanceof Zombie && $zombie->getNamedTag() === "Life" && $event->getDamage() >= $zombie->getHealth()){
            
    //Pre death.
        
    }
    }
    Post-death:
    PHP:
    public function onDeath(EntityDeathEvent $event){
        if((
    $zombie $event->getEntity()) instanceof Zombie && $zombie->getNamedTag() === "Life"){
            
    //Post death.
        
    }
    }
     
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Make sure you handle pre-death at the appropriate priority. If you are not cancelling the event or otherwise modifying it, make sure you use the MONITOR priority with @ignoreCancelled.
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Heard a lot about those, but does that actually make any difference?
     
  5. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    No, we put them there for fun :facepalm:
    sarcasam
     
    HimbeersaftLP likes this.
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.