diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 53e690d7..e0a0a43c 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -170,7 +170,7 @@ class PocketMinecraftServer{ public function titleTick(){ $time = microtime(true); if(defined("DEBUG") and DEBUG >= 0){ - echo "\x1b]0;NostalgiaCore " . MAJOR_VERSION . " | Online " . count($this->clients) . "/" . $this->maxClients . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "MB | U " . round(($this->interface->bandwidth[1] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " D " . round(($this->interface->bandwidth[0] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " kB/s | TPS " . $this->getTPS() . "\x07"; + //echo "\x1b]0;NostalgiaCore " . MAJOR_VERSION . " | Online " . count($this->clients) . "/" . $this->maxClients . " | RAM " . round((memory_get_usage() / 1024) / 1024, 2) . "MB | U " . round(($this->interface->bandwidth[1] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " D " . round(($this->interface->bandwidth[0] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2) . " kB/s | TPS " . $this->getTPS() . "\x07"; } $this->interface->bandwidth = [0, 0, $time]; diff --git a/src/entity/Creature.php b/src/entity/Creature.php index 656a8589..b9018b19 100644 --- a/src/entity/Creature.php +++ b/src/entity/Creature.php @@ -16,6 +16,11 @@ abstract class Creature extends Living{ $this->searchForClosestPlayers = true; } + public function update($now){ + $this->handlePrePlayerSearcher(); + return parent::update($now); + } + public function handlePrePlayerSearcher(){ parent::handlePrePlayerSearcher(); if($this->closestPlayerEID !== false && !isset($this->level->entityList[$this->closestPlayerEID])){ diff --git a/src/entity/ai/tasks/TaskAttackPlayer.php b/src/entity/ai/tasks/TaskAttackPlayer.php index 57105c95..4b757431 100644 --- a/src/entity/ai/tasks/TaskAttackPlayer.php +++ b/src/entity/ai/tasks/TaskAttackPlayer.php @@ -70,7 +70,7 @@ class TaskAttackPlayer extends TaskBase } } - $closestTarget = $e->closestPlayerDist <= $this->rangeSquared ? ($e->level->entityList[$e->closestPlayerEID] ?? null) : null; + $closestTarget = $e->closestPlayerDist <= $this->rangeSquared ? $e->level->entityList[$e->closestPlayerEID] : null; if($closestTarget != null){ $e->target = $closestTarget; //TODO dont save entity object ? diff --git a/src/entity/ai/tasks/TaskLookAtPlayer.php b/src/entity/ai/tasks/TaskLookAtPlayer.php index a557eb74..65a9f1e3 100644 --- a/src/entity/ai/tasks/TaskLookAtPlayer.php +++ b/src/entity/ai/tasks/TaskLookAtPlayer.php @@ -12,7 +12,7 @@ class TaskLookAtPlayer extends TaskBase{ } protected function findTarget(Creature $e, $r){ - return $e->closestPlayerDist > $r*$r ? null : ($e->level->entityList[$e->closestPlayerEID] ?? null); + return $e->closestPlayerDist > $r*$r ? null : $e->level->entityList[$e->closestPlayerEID]; } public function onStart(EntityAI $ai){ diff --git a/src/entity/ai/tasks/TaskRangedAttack.php b/src/entity/ai/tasks/TaskRangedAttack.php index 482f4446..5bcb627f 100644 --- a/src/entity/ai/tasks/TaskRangedAttack.php +++ b/src/entity/ai/tasks/TaskRangedAttack.php @@ -113,8 +113,8 @@ class TaskRangedAttack extends \TaskBase return true; } } - //TODO fix closestPlayerEID being not in entityList - $closestTarget = $e->closestPlayerDist <= $this->rangeSquared ? ($e->level->entityList[$e->closestPlayerEID] ?? null) : null; + + $closestTarget = $e->closestPlayerDist <= $this->rangeSquared ? $e->level->entityList[$e->closestPlayerEID] : null; if($closestTarget != null){ $e->target = $closestTarget; //TODO dont save entity object ? diff --git a/src/world/Level.php b/src/world/Level.php index e9a4d1cd..ea0c6b1a 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -670,8 +670,9 @@ class Level{ } public function addBlockToSendQueue($x, $y, $z, $id, $meta){ - if(!$this->forceDisableBlockQueue) + if(!$this->forceDisableBlockQueue){ $this->queuedBlockUpdates["$x $y $z"] = [$x, $y, $z, $id, $meta]; + } } public function setBlock(Vector3 $pos, Block $block, $update = true, $tiles = false, $direct = false){