mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
Faster chunk distance ordering
This commit is contained in:
parent
90effd173b
commit
044b25ccd2
1 changed files with 8 additions and 5 deletions
|
|
@ -123,14 +123,17 @@ class Player{
|
||||||
$X = $this->entity->x / 16;
|
$X = $this->entity->x / 16;
|
||||||
$Z = $this->entity->z / 16;
|
$Z = $this->entity->z / 16;
|
||||||
$Y = $this->entity->y / 16;
|
$Y = $this->entity->y / 16;
|
||||||
$v = new Vector3($X, $Y / 4, $Z);
|
|
||||||
$this->chunksOrder = array();
|
$this->chunksOrder = array();
|
||||||
for($x = 0; $x < 16; ++$x){
|
for($y = 0; $y < 8; ++$y){
|
||||||
for($z = 0; $z < 16; ++$z){
|
$distY = abs($Y - $y) / 4;
|
||||||
for($y = 0; $y < 8; ++$y){
|
for($x = 0; $x < 16; ++$x){
|
||||||
|
$distX = abs($X - $x);
|
||||||
|
for($z = 0; $z < 16; ++$z){
|
||||||
|
$distZ = abs($Z - $z);
|
||||||
$d = $x.":".$y.":".$z;
|
$d = $x.":".$y.":".$z;
|
||||||
if(!isset($this->chunksLoaded[$d])){
|
if(!isset($this->chunksLoaded[$d])){
|
||||||
$this->chunksOrder[$d] = $v->distance(new Vector3($x + 0.5, $y / 4, $z + 0.5));
|
$this->chunksOrder[$d] = $distX + $distY + $distZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue