本文整理汇总了PHP中pocketmine\entity\Entity::entityBaseTick方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::entityBaseTick方法的具体用法?PHP Entity::entityBaseTick怎么用?PHP Entity::entityBaseTick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\entity\Entity
的用法示例。
在下文中一共展示了Entity::entityBaseTick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: entityBaseTick
public function entityBaseTick($tickDiff = 1)
{
Timings::$timerEntityBaseTick->startTiming();
if (!$this->isCreated()) {
return false;
}
$hasUpdate = Entity::entityBaseTick($tickDiff);
if ($this->attackTime > 0) {
$this->attackTime -= $tickDiff;
}
if ($this->isInsideOfSolid()) {
$hasUpdate = true;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
$this->attack($ev->getFinalDamage(), $ev);
}
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;
}
示例2: entityBaseTick
public function entityBaseTick($tickDiff = 1)
{
Timings::$timerLivingEntityBaseTick->startTiming();
$hasUpdate = parent::entityBaseTick($tickDiff);
if ($this->isAlive()) {
if ($this->isInsideOfSolid()) {
$hasUpdate = true;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
$this->attack($ev->getFinalDamage(), $ev);
}
if (!$this->hasEffect(Effect::WATER_BREATHING) and $this->isInsideOfWater()) {
if ($this instanceof WaterAnimal) {
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
} else {
$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 {
if ($this instanceof WaterAnimal) {
$hasUpdate = true;
$airTicks = $this->getDataProperty(self::DATA_AIR) - $tickDiff;
if ($airTicks <= -20) {
$airTicks = 0;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 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);
}
}
}
if ($this->attackTime > 0) {
$this->attackTime -= $tickDiff;
}
Timings::$timerLivingEntityBaseTick->stopTiming();
return $hasUpdate;
}
示例3: entityBaseTick
public function entityBaseTick($tickDiff = 1)
{
Timings::$timerEntityBaseTick->startTiming();
if ($this->dead === true) {
++$this->deadTicks;
if ($this->deadTicks >= 10) {
$this->despawnFromAll();
if (!$this instanceof Player) {
$this->close();
}
}
Timings::$timerEntityBaseTick->stopTiming();
return $this->deadTicks < 10;
}
parent::entityBaseTick($tickDiff);
if ($this->dead !== true and $this->isInsideOfSolid()) {
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
$this->attack($ev->getFinalDamage(), $ev);
}
if ($this->dead !== true and $this->isInsideOfWater()) {
$this->airTicks -= $tickDiff;
if ($this->airTicks <= -20) {
$this->airTicks = 0;
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
$this->attack($ev->getFinalDamage(), $ev);
}
} else {
$this->airTicks = 300;
}
if ($this->attackTime > 0) {
$this->attackTime -= $tickDiff;
}
Timings::$timerEntityBaseTick->stopTiming();
}
示例4: entityBaseTick
public function entityBaseTick()
{
Timings::$timerEntityBaseTick->startTiming();
parent::entityBaseTick();
if ($this->dead !== true and $this->isInsideOfSolid()) {
$this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1));
if (!$ev->isCancelled()) {
$this->attack($ev->getFinalDamage(), $ev);
}
}
if ($this->dead !== true and $this->isInsideOfWater()) {
--$this->airTicks;
if ($this->airTicks <= -20) {
$this->airTicks = 0;
$this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2));
if (!$ev->isCancelled()) {
$this->attack($ev->getFinalDamage(), $ev);
}
}
$this->extinguish();
} else {
$this->airTicks = 300;
}
if ($this->attackTime > 0) {
--$this->attackTime;
}
Timings::$timerEntityBaseTick->stopTiming();
}