Limited death animation to Living entities

This commit is contained in:
Shoghi Cervantes 2014-12-09 14:57:28 +01:00
parent 04ecbd1a76
commit ea8f10efa4
2 changed files with 19 additions and 7 deletions

View File

@ -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;

View File

@ -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()){