From abe7846bb9f5a3f7c720db87a84ed8d9651799a4 Mon Sep 17 00:00:00 2001 From: ArkQuark <74979909+ArkQuark@users.noreply.github.com> Date: Tue, 21 Feb 2023 15:37:42 +0300 Subject: [PATCH] Open player's eyes for mobs --- src/entity/ai/EntityAI.php | 4 +++- src/entity/ai/path/PathFollower.php | 7 +++++-- src/network/protocol/packet/AddMobPacket.php | 6 +++--- src/network/protocol/packet/EntityDataPacket.php | 8 ++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/entity/ai/EntityAI.php b/src/entity/ai/EntityAI.php index 7edce1f0..96ff9c09 100644 --- a/src/entity/ai/EntityAI.php +++ b/src/entity/ai/EntityAI.php @@ -55,7 +55,9 @@ class EntityAI } public function updateTasks(){ - if(!($this->entity instanceof Entity)) return; + if(!isset($entity) or !($this->entity instanceof Entity)){ + return; + } foreach($this->tasks as $t){ if(!$t->isStarted && $t->canBeExecuted($this)){ $t->isStarted = true; diff --git a/src/entity/ai/path/PathFollower.php b/src/entity/ai/path/PathFollower.php index 85d0ddb9..2a1a1097 100644 --- a/src/entity/ai/path/PathFollower.php +++ b/src/entity/ai/path/PathFollower.php @@ -11,11 +11,14 @@ class PathFollower{ } public function followPath(){ - if($this->entity->path != null && (is_array($this->entity->path) && count($this->entity->path) <= 0 || $this->entity->currentIndex >= count($this->entity->path))){ + if(!isset($entity) or $this->entity->path == null){ + return; + } + if((is_array($this->entity->path) && count($this->entity->path) <= 0 || $this->entity->currentIndex >= count($this->entity->path))){ $this->entity->path = null; $this->entity->currentIndex = 0; $this->entity->currentNode = false; - }elseif($this->entity->path != null && ($this->entity->currentNode == false || $this->entity->ai->mobController->moveTo($this->entity->currentNode->x, $this->entity->currentNode->y, $this->entity->currentNode->z) === false)){ + }elseif(($this->entity->currentNode == false || $this->entity->ai->mobController->moveTo($this->entity->currentNode->x, $this->entity->currentNode->y, $this->entity->currentNode->z) === false)){ $this->entity->currentNode = $this->entity->path[$this->entity->currentIndex++]; } } diff --git a/src/network/protocol/packet/AddMobPacket.php b/src/network/protocol/packet/AddMobPacket.php index 5b2d9a90..70b3bfca 100644 --- a/src/network/protocol/packet/AddMobPacket.php +++ b/src/network/protocol/packet/AddMobPacket.php @@ -22,9 +22,9 @@ class AddMobPacket extends RakNetDataPacket{ $this->reset(); $this->putInt($this->eid); $this->putInt($this->type); - $this->putFloat($this->x); - $this->putFloat($this->y); - $this->putFloat($this->z); + $this->putInt($this->x); + $this->putInt($this->y); + $this->putInt($this->z); $this->putByte($this->yaw); $this->putByte($this->pitch); $this->put(Utils::writeMetadata($this->metadata)); diff --git a/src/network/protocol/packet/EntityDataPacket.php b/src/network/protocol/packet/EntityDataPacket.php index 01b2cafb..c914bd20 100644 --- a/src/network/protocol/packet/EntityDataPacket.php +++ b/src/network/protocol/packet/EntityDataPacket.php @@ -11,17 +11,17 @@ class EntityDataPacket extends RakNetDataPacket{ } public function decode(){ - $this->x = $this->getShort(); + $this->x = $this->getInt(); $this->y = $this->getByte(); - $this->z = $this->getShort(); + $this->z = $this->getInt(); $this->namedtag = $this->get(true); } public function encode(){ $this->reset(); - $this->putShort($this->x); + $this->putInt($this->x); $this->putByte($this->y); - $this->putShort($this->z); + $this->putInt($this->z); $this->put($this->namedtag); }