changed pathfinder(hopefully one last time)

This commit is contained in:
GameHerobrine 2022-12-26 02:16:24 +03:00
parent 8c12e0de26
commit e11c40f645
28 changed files with 401 additions and 416 deletions

View file

@ -12,9 +12,10 @@ class MobController
}
public function moveNonInstant($x, $y, $z){
if($x === $this->entity->x && $y === $this->entity->y && $z === $this->entity->z){
if($x == 0 && $y == 0 && $z == 0){
return false; //failed
}
$ox = ($x > 0 ? 1 : ($x < 0 ? -1 : 0));
$oy = ($y > 0 ? 1 : ($y < 0 ? -1 : 0));
$oz = ($z > 0 ? 1 : ($z < 0 ? -1 : 0));
@ -27,6 +28,10 @@ class MobController
return true;
}
public function moveTo($x, $y, $z){
return $this->moveNonInstant($x - floor($this->entity->x), $y - floor($this->entity->y), $z - floor($this->entity->z));
}
public function faceEntity(Vector3 $v){
$d = $v->subtract($this->entity)->normalize();
$dx = $d->x;