diff --git a/src/pocketmine/level/format/anvil/RegionLoader.php b/src/pocketmine/level/format/anvil/RegionLoader.php index 86d098602..41f360170 100644 --- a/src/pocketmine/level/format/anvil/RegionLoader.php +++ b/src/pocketmine/level/format/anvil/RegionLoader.php @@ -58,6 +58,7 @@ class RegionLoader{ private function cleanGarbage(){ $sectors = array(); + $maxSector = 1; foreach($this->locationTable as $index => $data){ //Calculate file usage if($data[0] === 0 or $data[1] === 0){ $this->locationTable[$index] = array(0, 0); @@ -65,9 +66,16 @@ class RegionLoader{ } for($i = 0; $i < $data[1]; ++$i){ $sectors[$data[0]] = $index; + if($data[0] > $maxSector){ + $maxSector = $data[0]; + } } } + if(count($sectors) === ($maxSector - 2)){ //No collection needed + return 0; + } + ksort($sectors); $shift = 0; $lastSector = 1; //First chunk - 1