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

Solved Getting the damager on the EntityDamageEvent

Discussion in 'Development' started by MalakasPlayzMCPE, Apr 29, 2018.

  1. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I am trying to get the damager from the EntityDamageEvent but I always get errors. I use $event->getDamager();
     
  2. Miste

    Miste Baby Zombie

    Messages:
    109
    GitHub:
    Misteboss
    You can only get the damager if the EntityDamageEvent is an instance of the EntityDamageByEntityEvent or the EntityDamageByBlockEvent.
     
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    ok, I will try
     
  4. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Sorry for replying late ;D
    PHP:
    if($event instanceof EntityDamageByEntityEvent){
    $damager $event->getDamager();
    }
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    No problem. This thing is already solved but I always learn more when someone replies.
     
    xXNiceAssassinlo YT likes this.
  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.