mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
Better chunk distance calculation
This commit is contained in:
parent
34f0e5170b
commit
23dc1033d5
1 changed files with 3 additions and 3 deletions
|
|
@ -76,15 +76,15 @@ class Player{
|
||||||
if(!($this->entity instanceof Entity)){
|
if(!($this->entity instanceof Entity)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$X = (int) min(15, round($this->entity->x / 16));
|
$X = $this->entity->x / 16;
|
||||||
$Z = (int) min(15, round($this->entity->z / 16));
|
$Z = $this->entity->z / 16;
|
||||||
$v = new Vector2($X, $Z);
|
$v = new Vector2($X, $Z);
|
||||||
$this->chunksOrder = array();
|
$this->chunksOrder = array();
|
||||||
for($x = 0; $x < 16; ++$x){
|
for($x = 0; $x < 16; ++$x){
|
||||||
for($z = 0; $z < 16; ++$z){
|
for($z = 0; $z < 16; ++$z){
|
||||||
$d = $x.":".$z;
|
$d = $x.":".$z;
|
||||||
if(!isset($this->chunksLoaded[$d])){
|
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…
Add table
Add a link
Reference in a new issue