mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
more entity optimizations
This commit is contained in:
parent
2b0ad36e14
commit
2d9b37aa9c
12 changed files with 44 additions and 62 deletions
|
|
@ -6,6 +6,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
|||
|
||||
public $target, $ai;
|
||||
public $pathFinder, $path = null, $currentIndex = 0, $currentNode, $pathFollower;
|
||||
public $ticksExisted = 0;
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array()){
|
||||
$this->target = false;
|
||||
$this->ai = new EntityAI($this);
|
||||
|
|
@ -15,7 +16,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
|||
$this->canBeAttacked = true;
|
||||
$this->hasGravity = true;
|
||||
$this->hasKnockback = true;
|
||||
if(self::$despawnMobs) $this->server->schedule(self::$despawnTimer, [$this, "close"]); //900*20
|
||||
//if(self::$despawnMobs) $this->server->schedule(self::$despawnTimer, [$this, "close"]); //900*20
|
||||
}
|
||||
public function fall(){
|
||||
$dmg = floor($this->fallDistance - 3);
|
||||
|
|
@ -62,6 +63,9 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
|||
}
|
||||
|
||||
public function update(){
|
||||
if(self::$despawnMobs && ++$this->ticksExisted > self::$despawnTimer){
|
||||
$this->close();
|
||||
}
|
||||
if(!$this->dead && Entity::$allowedAI && $this->idleTime <= 0) {
|
||||
$this->ai->updateTasks();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue