fixed sending of chunk changes

This commit is contained in:
GameHerobrine 2024-07-19 05:48:00 +03:00
parent 66d847c82f
commit b182e35f2a

View file

@ -397,6 +397,7 @@ class Level{
if(count($this->changedCount) > 0){ if(count($this->changedCount) > 0){
arsort($this->changedCount); arsort($this->changedCount);
$resendChunks = []; $resendChunks = [];
$reorder = false;
foreach($this->changedCount as $index => $count){ foreach($this->changedCount as $index => $count){
if($count < 582){//Optimal value, calculated using the relation between minichunks and single packets if($count < 582){//Optimal value, calculated using the relation between minichunks and single packets
break; break;
@ -404,10 +405,17 @@ class Level{
foreach($this->players as $p){ foreach($this->players as $p){
unset($p->chunksLoaded[$index]); unset($p->chunksLoaded[$index]);
} }
$reorder = true;
unset($this->changedBlocks[$index]); unset($this->changedBlocks[$index]);
} }
$this->changedCount = []; $this->changedCount = [];
if($reorder){
foreach($this->players as $p){
$p->orderChunks();
}
}
if(count($this->changedBlocks) > 0){ if(count($this->changedBlocks) > 0){
foreach($this->changedBlocks as $i => $blocks){ foreach($this->changedBlocks as $i => $blocks){
foreach($blocks as $b){ foreach($blocks as $b){