Beispiel #1
0
 /**
  * @param float             $damage
  * @param EntityDamageEvent $source
  *
  */
 public function attack($damage, EntityDamageEvent $source)
 {
     if ($this->hasEffect(Effect::FIRE_RESISTANCE) and ($source->getCause() === EntityDamageEvent::CAUSE_FIRE or $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK or $source->getCause() === EntityDamageEvent::CAUSE_LAVA)) {
         $source->setCancelled();
     }
     if ($source instanceof EntityDamageByEntityEvent && $source->getCause() === EntityDamageEvent::CAUSE_PROJECTILE) {
         $e = $source->getDamager();
         if ($source instanceof EntityDamageByChildEntityEvent) {
             $e = $source->getChild();
         }
         if ($e instanceof ThrownExpBottle || $e instanceof ThrownPotion) {
             $source->setCancelled();
         }
     }
     $this->server->getPluginManager()->callEvent($source);
     if ($source->isCancelled()) {
         return;
     }
     $this->setLastDamageCause($source);
     $this->getHealth() - $source->getFinalDamage() <= 0 ? $this->setHealth(0) : $this->setHealth($this->getHealth() - $source->getFinalDamage());
 }