Ejemplo n.º 1
0
 public function initEntity()
 {
     parent::initEntity();
     if ($this->getDataProperty(self::DATA_AGEABLE_FLAGS) === null) {
         $this->setDataProperty(self::DATA_AGEABLE_FLAGS, self::DATA_TYPE_BYTE, 0);
     }
 }
Ejemplo n.º 2
0
 public function entityBaseTick($tickDiff = 1)
 {
     Timings::$timerEntityBaseTick->startTiming();
     $hasUpdate = parent::entityBaseTick($tickDiff);
     $this->attackDelay += $tickDiff;
     if ($this instanceof Enderman) {
         if ($this->level->getBlock(new Vector3(Math::floorFloat($this->x), (int) $this->y, Math::floorFloat($this->z))) instanceof Water) {
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
             $this->attack($ev->getFinalDamage(), $ev);
             $this->move(mt_rand(-20, 20), mt_rand(-20, 20), mt_rand(-20, 20));
         }
     } else {
         if (!$this->hasEffect(Effect::WATER_BREATHING) && $this->isInsideOfWater()) {
             $hasUpdate = true;
             $airTicks = $this->getDataProperty(self::DATA_AIR) - $tickDiff;
             if ($airTicks <= -20) {
                 $airTicks = 0;
                 $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
                 $this->attack($ev->getFinalDamage(), $ev);
             }
             $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks);
         } else {
             $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
         }
     }
     Timings::$timerEntityBaseTick->stopTiming();
     return $hasUpdate;
 }