mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
block ticking & entity optimizations
This commit is contained in:
parent
177d8b53ab
commit
2ad5a5650e
8 changed files with 44 additions and 33 deletions
|
|
@ -539,13 +539,6 @@ class Entity extends Position
|
|||
|
||||
$ywMin = floor($aABB->minY + 0.4);
|
||||
$ywMax = ceil($aABB->maxY - 0.4);
|
||||
|
||||
$x0 = $x0 < 0 ? 0 : $x0;
|
||||
$y0 = $y0 < 0 ? 0 : $y0;
|
||||
$z0 = $z0 < 0 ? 0 : $z0;
|
||||
$x1 = $x1 > 256 ? 256 : $x1;
|
||||
$y1 = $y1 > 128 ? 128 : $y1;
|
||||
$z1 = $z1 > 256 ? 256 : $z1;
|
||||
for($x = $x0; $x < $x1; ++$x){
|
||||
for($y = $y0; $y < $y1; ++$y){
|
||||
for($z = $z0; $z < $z1; ++$z){
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
|||
//if(!$this->hasPath() && $this->pathFinder instanceof ITileNavigator){
|
||||
// $this->path = $this->pathFinder->navigate(new PathTileXYZ($this->x, $this->y, $this->z, $this->level), new PathTileXYZ($this->x + mt_rand(-10, 10), $this->y + mt_rand(-1, 1), $this->z + mt_rand(-10, 10), $this->level), 10);
|
||||
//}
|
||||
$this->pathFollower->followPath();
|
||||
//$this->pathFollower->followPath();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class MobController
|
|||
;
|
||||
|
||||
}
|
||||
$this->faceEntity($this->entity->add($ox, $oy, $oz));
|
||||
$this->faceEntity($ox, $oy, $oz);
|
||||
if($this->entity->knockbackTime <= 0){
|
||||
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
||||
}
|
||||
|
|
@ -76,10 +76,17 @@ class MobController
|
|||
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;
|
||||
$dz = $d->z;
|
||||
public function faceEntity($x, $y, $z){
|
||||
$len = sqrt($x*$x + $z*$z + $y*$y);
|
||||
//$d = $len == 0 ?//$v->subtract($this->entity)->normalize();
|
||||
if($len == 0){
|
||||
$dx = 0;
|
||||
$dz = 0;
|
||||
}else{
|
||||
$dx = $x / $len;
|
||||
$dz = $z / $len;
|
||||
}
|
||||
|
||||
|
||||
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg(atan($dx / $dz)));
|
||||
$thetaOffset = $dz < 0 ? 90 : 270;
|
||||
|
|
@ -97,10 +104,10 @@ class MobController
|
|||
if($pitch){
|
||||
$diff = sqrt($x * $x + $z * $z);
|
||||
$calcPitch = $diff == 0 ? ($y < 0 ? -90 : 90) : rad2deg(atan($y / $diff));
|
||||
$this->entity->pitch = $this->entity->type === MOB_CHICKEN ? -$calcPitch : $calcPitch;
|
||||
$this->entity->pitch = $calcPitch;
|
||||
}
|
||||
|
||||
$this->entity->server->query("UPDATE entities SET pitch = ".$this->entity->pitch.", yaw = ".$this->entity->yaw." WHERE EID = ".$this->entity->eid.";");
|
||||
//$this->entity->server->query("UPDATE entities SET pitch = ".$this->entity->pitch.", yaw = ".$this->entity->yaw." WHERE EID = ".$this->entity->eid.";");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue