From e13b1f28ce3951d7ebe5166c07fe8815ac8f3882 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Mon, 15 Jul 2024 05:55:38 +0300 Subject: [PATCH] chunks will reorder if player changed chunk while the world was sending it(should result in visually faster chunk loading) --- src/Player.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Player.php b/src/Player.php index 4f2a9aaf..89939251 100755 --- a/src/Player.php +++ b/src/Player.php @@ -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); }