mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
Improved Player::orderChunks()
This commit is contained in:
parent
523c4390fa
commit
3ab3526404
1 changed files with 9 additions and 12 deletions
|
|
@ -130,20 +130,17 @@ class Player{
|
||||||
if(!($this->entity instanceof Entity) or $this->connected === false){
|
if(!($this->entity instanceof Entity) or $this->connected === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$X = $this->entity->x / 16;
|
$X = ($this->entity->x - 0.5) / 16;
|
||||||
$Z = $this->entity->z / 16;
|
$Z = ($this->entity->z - 0.5) / 16;
|
||||||
$Y = $this->entity->y / 16;
|
$v = new Vector2($X, $Z);
|
||||||
|
|
||||||
$this->chunksOrder = array();
|
$this->chunksOrder = array();
|
||||||
for($y = 0; $y < 8; ++$y){
|
for($x = 0; $x < 16; ++$x){
|
||||||
$distY = abs($Y - $y) / 4;
|
for($z = 0; $z < 16; ++$z){
|
||||||
for($x = 0; $x < 16; ++$x){
|
$dist = $v->distance(new Vector2($x, $z));
|
||||||
$distX = abs($X - $x);
|
for($y = 0; $y < 8; ++$y){
|
||||||
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] = $distX + $distY + $distZ;
|
$this->chunksOrder[$d] = $dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +148,7 @@ class Player{
|
||||||
asort($this->chunksOrder);
|
asort($this->chunksOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextChunk($repeat = false){
|
public function getNextChunk(){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue