Open player's eyes for mobs

This commit is contained in:
ArkQuark 2023-02-21 15:37:42 +03:00
parent b6934024da
commit abe7846bb9
4 changed files with 15 additions and 10 deletions

View file

@ -55,7 +55,9 @@ class EntityAI
} }
public function updateTasks(){ public function updateTasks(){
if(!($this->entity instanceof Entity)) return; if(!isset($entity) or !($this->entity instanceof Entity)){
return;
}
foreach($this->tasks as $t){ foreach($this->tasks as $t){
if(!$t->isStarted && $t->canBeExecuted($this)){ if(!$t->isStarted && $t->canBeExecuted($this)){
$t->isStarted = true; $t->isStarted = true;

View file

@ -11,11 +11,14 @@ class PathFollower{
} }
public function followPath(){ 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->path = null;
$this->entity->currentIndex = 0; $this->entity->currentIndex = 0;
$this->entity->currentNode = false; $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++]; $this->entity->currentNode = $this->entity->path[$this->entity->currentIndex++];
} }
} }

View file

@ -22,9 +22,9 @@ class AddMobPacket extends RakNetDataPacket{
$this->reset(); $this->reset();
$this->putInt($this->eid); $this->putInt($this->eid);
$this->putInt($this->type); $this->putInt($this->type);
$this->putFloat($this->x); $this->putInt($this->x);
$this->putFloat($this->y); $this->putInt($this->y);
$this->putFloat($this->z); $this->putInt($this->z);
$this->putByte($this->yaw); $this->putByte($this->yaw);
$this->putByte($this->pitch); $this->putByte($this->pitch);
$this->put(Utils::writeMetadata($this->metadata)); $this->put(Utils::writeMetadata($this->metadata));

View file

@ -11,17 +11,17 @@ class EntityDataPacket extends RakNetDataPacket{
} }
public function decode(){ public function decode(){
$this->x = $this->getShort(); $this->x = $this->getInt();
$this->y = $this->getByte(); $this->y = $this->getByte();
$this->z = $this->getShort(); $this->z = $this->getInt();
$this->namedtag = $this->get(true); $this->namedtag = $this->get(true);
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putShort($this->x); $this->putInt($this->x);
$this->putByte($this->y); $this->putByte($this->y);
$this->putShort($this->z); $this->putInt($this->z);
$this->put($this->namedtag); $this->put($this->namedtag);
} }