Region loaders don't need to know their own coordinates

This commit is contained in:
Dylan K. Taylor 2018-10-04 16:37:19 +01:00
parent 41f335e7d9
commit b0f1863c4f
2 changed files with 3 additions and 17 deletions

View File

@ -254,7 +254,7 @@ abstract class RegionLevelProvider extends BaseLevelProvider{
if(!isset($this->regions[$index = Level::chunkHash($regionX, $regionZ)])){ if(!isset($this->regions[$index = Level::chunkHash($regionX, $regionZ)])){
$path = $this->pathToRegion($regionX, $regionZ); $path = $this->pathToRegion($regionX, $regionZ);
$region = new RegionLoader($path, $regionX, $regionZ); $region = new RegionLoader($path);
try{ try{
$region->open(); $region->open();
}catch(CorruptedRegionException $e){ }catch(CorruptedRegionException $e){
@ -267,7 +267,7 @@ abstract class RegionLevelProvider extends BaseLevelProvider{
rename($path, $backupPath); rename($path, $backupPath);
$logger->error("Corrupted region file has been backed up to " . $backupPath); $logger->error("Corrupted region file has been backed up to " . $backupPath);
$region = new RegionLoader($path, $regionX, $regionZ); $region = new RegionLoader($path);
$region->open(); //this will create a new empty region to replace the corrupted one $region->open(); //this will create a new empty region to replace the corrupted one
} }

View File

@ -39,10 +39,6 @@ class RegionLoader{
public static $COMPRESSION_LEVEL = 7; public static $COMPRESSION_LEVEL = 7;
/** @var int */
protected $x;
/** @var int */
protected $z;
/** @var string */ /** @var string */
protected $filePath; protected $filePath;
/** @var resource */ /** @var resource */
@ -54,9 +50,7 @@ class RegionLoader{
/** @var int */ /** @var int */
public $lastUsed = 0; public $lastUsed = 0;
public function __construct(string $filePath, int $regionX, int $regionZ){ public function __construct(string $filePath){
$this->x = $regionX;
$this->z = $regionZ;
$this->filePath = $filePath; $this->filePath = $filePath;
} }
@ -340,14 +334,6 @@ class RegionLoader{
$this->locationTable = array_fill(0, 1024, [0, 0, 0]); $this->locationTable = array_fill(0, 1024, [0, 0, 0]);
} }
public function getX() : int{
return $this->x;
}
public function getZ() : int{
return $this->z;
}
public function getFilePath() : string{ public function getFilePath() : string{
return $this->filePath; return $this->filePath;
} }