chunks will reorder if player changed chunk while the world was sending it(should result in visually faster chunk loading)

This commit is contained in:
GameHerobrine 2024-07-15 05:55:38 +03:00
parent a980eda1be
commit e13b1f28ce

View file

@ -468,7 +468,9 @@ class Player{
$this->server->api->dhandle("player.armor", $data);
}
}
public $lastOrderX = 0;
public $lastOrderZ = 0;
public function orderChunks(){
if(!($this->entity instanceof Entity) or $this->connected === false){
return false;
@ -476,6 +478,8 @@ class Player{
$X = ((int)$this->entity->x) >> 4;
$Z = ((int)$this->entity->z) >> 4;
$this->chunksOrder = [];
$this->lastOrderX = $X;
$this->lastOrderZ = $Z;
if(self::$smallChunks){
$Y = ((int)$this->entity->y) >> 4;
$v = new Vector3($X, $Y, $Z);
@ -622,7 +626,9 @@ class Player{
}
$this->lastChunk = [$x, $z];
if($this->lastOrderX != ($this->entity->x >> 4) || $this->lastOrderZ != ($this->entity->z >> 4)){
$this->orderChunks();
}
$this->server->schedule(MAX_CHUNK_RATE, [$this, "getNextChunk"], $world);
}