diff --git a/src/entity/ai/EntityAI.php b/src/entity/ai/EntityAI.php index 7c9ffca7..98d56b5d 100644 --- a/src/entity/ai/EntityAI.php +++ b/src/entity/ai/EntityAI.php @@ -18,6 +18,8 @@ class EntityAI public $lastTask; + public $counter = 0; + public function __construct($entity){ $this->entity = $entity; $this->tasks = []; @@ -47,6 +49,9 @@ class EntityAI } public function updateTasks(){ + if($this->counter % 3 != 0){ + return; + } foreach($this->tasks as $t){ if(!$t->isStarted && $t->canBeExecuted($this)){ $t->isStarted = true; diff --git a/src/pmf/PMFLevel.php b/src/pmf/PMFLevel.php index e5b413b1..27b3373b 100644 --- a/src/pmf/PMFLevel.php +++ b/src/pmf/PMFLevel.php @@ -332,7 +332,12 @@ class PMFLevel extends PMF{ $aX = $x - ($X << 4); $aZ = $z - ($Z << 4); $aY = $y - ($Y << 4); - $b = ord($this->chunks[$index][$Y][(int) ($aY + ($aX << 5) + ($aZ << 9))]); + if(is_array($this->chunks) && is_array($this->chunks[$index]) && is_string($this->chunks[$index][$Y])){ + $b = ord($this->chunks[$index][$Y][(int) ($aY + ($aX << 5) + ($aZ << 9))]); + }else{ //php8 fix + $b = 0; + } + return $b; } @@ -372,7 +377,12 @@ class PMFLevel extends PMF{ $aX = $x - ($X << 4); $aZ = $z - ($Z << 4); $aY = $y - ($Y << 4); - $m = ord($this->chunks[$index][$Y][(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))]); + if(is_array($this->chunks) && is_array($this->chunks[$index]) && is_string($this->chunks[$index][$Y])){ + $m = ord($this->chunks[$index][$Y][(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))]); + }else{ //php8 fix + $m = 0; + } + if(($y & 1) === 0){ $m = $m & 0x0F; }else{ diff --git a/src/world/MobSpawner.php b/src/world/MobSpawner.php index af77da8b..25f4e42d 100644 --- a/src/world/MobSpawner.php +++ b/src/world/MobSpawner.php @@ -20,7 +20,6 @@ class MobSpawner{ } public function handle(){ - return false; if($this->countEntities() > self::MOB_LIMIT || count($this->level->players) <= 0){ return false; //not spawning }