attack() public method

public attack ( $damage, EntityDamageEvent $source )
$source pocketmine\event\entity\EntityDamageEvent
Exemplo n.º 1
0
 public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC)
 {
     parent::attack($damage, $source);
     if (!$this->hit instanceof Player and $source instanceof EntityDamageByEntityEvent) {
         if ($source->getDamager() instanceof Player) {
             $this->hit = $source->getDamager();
         }
     }
 }
Exemplo n.º 2
0
 public function attack($damage, EntityDamageEvent $source)
 {
     if ($this->isKnockback() > 0) {
         return;
     }
     parent::attack($damage, $source);
     if ($source->isCancelled() || !$source instanceof EntityDamageByEntityEvent) {
         return;
     }
     $this->stayTime = 0;
     $this->moveTime = 0;
     $this->baseTarget = null;
     $damager = $source->getDamager();
     $motion = (new Vector3($this->x - $damager->x, $this->y - $damager->y, $this->z - $damager->z))->normalize();
     $this->motionX = $motion->x * 0.19;
     $this->motionZ = $motion->z * 0.19;
     if ($this instanceof FlyingEntity) {
         $this->motionY = $motion->y * 0.19;
     } else {
         $this->motionY = 0.5;
     }
 }
Exemplo n.º 3
0
 public function attack($damage, EntityDamageEvent $source)
 {
     if ($source->isCancelled()) {
         return;
     }
     if ($source->getCause() == EntityDamageEvent::CAUSE_FALL) {
         $source->setCancelled();
         return;
     }
     parent::attack($damage, $source);
 }