mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
RegionLoader: added utility function getProportionUnusedSpace()
This commit is contained in:
parent
63b14a083c
commit
9bb8a8f761
@ -404,6 +404,20 @@ class RegionLoader{
|
|||||||
return $result;
|
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{
|
public function getX() : int{
|
||||||
return $this->x;
|
return $this->x;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user