mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Better chunk distance calculation
This commit is contained in:
parent
34f0e5170b
commit
23dc1033d5
@ -76,15 +76,15 @@ class Player{
|
||||
if(!($this->entity instanceof Entity)){
|
||||
return false;
|
||||
}
|
||||
$X = (int) min(15, round($this->entity->x / 16));
|
||||
$Z = (int) min(15, round($this->entity->z / 16));
|
||||
$X = $this->entity->x / 16;
|
||||
$Z = $this->entity->z / 16;
|
||||
$v = new Vector2($X, $Z);
|
||||
$this->chunksOrder = array();
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$d = $x.":".$z;
|
||||
if(!isset($this->chunksLoaded[$d])){
|
||||
$this->chunksOrder[$d] = $v->distance(new Vector2($x, $z));
|
||||
$this->chunksOrder[$d] = $v->distance(new Vector2($x + 0.5, $z + 0.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user