From ea8f10efa441210d3201b7eb106309a203fd4631 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 9 Dec 2014 14:57:28 +0100 Subject: [PATCH] Limited death animation to Living entities --- src/pocketmine/entity/Entity.php | 11 ++++------- src/pocketmine/entity/Living.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 010263d31..e6b0091cd 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -528,16 +528,13 @@ abstract class Entity extends Location implements Metadatable{ $isPlayer = $this instanceof Player; if($this->dead === true){ - ++$this->deadTicks; - if($this->deadTicks >= 10){ - $this->despawnFromAll(); - if(!$isPlayer){ - $this->close(); - } + $this->despawnFromAll(); + if(!$isPlayer){ + $this->close(); } Timings::$tickEntityTimer->stopTiming(); - return $this->deadTicks < 10; + return false; } $hasUpdate = false; diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 424be86f5..7c792db1f 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -32,6 +32,7 @@ use pocketmine\item\Item as ItemItem; use pocketmine\math\Vector3; use pocketmine\nbt\tag\Short; use pocketmine\network\protocol\EntityEventPacket; +use pocketmine\Player; use pocketmine\Server; use pocketmine\utils\BlockIterator; @@ -150,6 +151,20 @@ abstract class Living extends Entity implements Damageable{ 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()){