what is wrong? PHP: $lastDmg = $p->getLastDamageCause(); if($lastDmg instanceof EntityDamageEvent){ if($lastDmg instanceof EntityDamageByEntityEvent){ $killer = $lastDmg->getDamager(); if($killer instanceof Player){ //somethimg return; } if($killer instanceof \pocketmine\entity\Projectile){ $damager = $killer->shootingEntity; } return; }
Actually, if you checked it is EntityDamageByEntityEvent, it must be an EntityDamageEvent. No need to check both. If Alice sends an arrow to kill Bob, getEntity returns Bob, getDamager is Alice and getChild is arrow. The event is instanceof EntityDamageByChildEntityEvent.