diff --git a/src/pocketmine/level/format/io/region/RegionLoader.php b/src/pocketmine/level/format/io/region/RegionLoader.php index e85f768db..14e6c9aa2 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -404,6 +404,20 @@ class RegionLoader{ return $result; } + /** + * Returns a float between 0 and 1 indicating what fraction of the file is currently unused space. + */ + public function getProportionUnusedSpace() : float{ + $size = $this->nextSector; + $used = self::FIRST_SECTOR; //header is always allocated + foreach($this->locationTable as $entry){ + if($entry !== null){ + $used += $entry->getSectorCount(); + } + } + return 1 - ($used / $size); + } + public function getX() : int{ return $this->x; }