mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
RegionWorldProvider: make loadRegion() return RegionLoader, fix 3 PHPStan null-reference errors
This commit is contained in:
parent
e810a68dd7
commit
219cf2126b
@ -130,7 +130,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
||||
return $this->path . "/region/r.$regionX.$regionZ." . static::getRegionFileExtension();
|
||||
}
|
||||
|
||||
protected function loadRegion(int $regionX, int $regionZ) : void{
|
||||
protected function loadRegion(int $regionX, int $regionZ) : RegionLoader{
|
||||
if(!isset($this->regions[$index = morton2d_encode($regionX, $regionZ)])){
|
||||
$path = $this->pathToRegion($regionX, $regionZ);
|
||||
|
||||
@ -153,6 +153,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
||||
|
||||
$this->regions[$index] = $region;
|
||||
}
|
||||
return $this->regions[$index];
|
||||
}
|
||||
|
||||
protected function unloadRegion(int $regionX, int $regionZ) : void{
|
||||
@ -221,9 +222,8 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
||||
if(!file_exists($this->pathToRegion($regionX, $regionZ))){
|
||||
return null;
|
||||
}
|
||||
$this->loadRegion($regionX, $regionZ);
|
||||
|
||||
$chunkData = $this->getRegion($regionX, $regionZ)->readChunk($chunkX & 0x1f, $chunkZ & 0x1f);
|
||||
$chunkData = $this->loadRegion($regionX, $regionZ)->readChunk($chunkX & 0x1f, $chunkZ & 0x1f);
|
||||
if($chunkData !== null){
|
||||
return $this->deserializeChunk($chunkData);
|
||||
}
|
||||
@ -233,9 +233,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
||||
|
||||
protected function writeChunk(int $chunkX, int $chunkZ, Chunk $chunk) : void{
|
||||
self::getRegionIndex($chunkX, $chunkZ, $regionX, $regionZ);
|
||||
$this->loadRegion($regionX, $regionZ);
|
||||
|
||||
$this->getRegion($regionX, $regionZ)->writeChunk($chunkX & 0x1f, $chunkZ & 0x1f, $this->serializeChunk($chunk));
|
||||
$this->loadRegion($regionX, $regionZ)->writeChunk($chunkX & 0x1f, $chunkZ & 0x1f, $this->serializeChunk($chunk));
|
||||
}
|
||||
|
||||
private function createRegionIterator() : \RegexIterator{
|
||||
@ -285,8 +283,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
||||
foreach($this->createRegionIterator() as $region){
|
||||
$regionX = ((int) $region[1]);
|
||||
$regionZ = ((int) $region[2]);
|
||||
$this->loadRegion($regionX, $regionZ);
|
||||
$count += $this->getRegion($regionX, $regionZ)->calculateChunkCount();
|
||||
$count += $this->loadRegion($regionX, $regionZ)->calculateChunkCount();
|
||||
$this->unloadRegion($regionX, $regionZ);
|
||||
}
|
||||
return $count;
|
||||
|
@ -500,21 +500,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/world/format/HeightArray.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method readChunk\\(\\) on pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionLoader\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/RegionWorldProvider.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method writeChunk\\(\\) on pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionLoader\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/RegionWorldProvider.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method calculateChunkCount\\(\\) on pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionLoader\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/RegionWorldProvider.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method setDirtyFlag\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
|
||||
count: 4
|
||||
|
Loading…
x
Reference in New Issue
Block a user