mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 05:15:13 +00:00
Chunk: stop exposing SplFixedArray<SubChunk> to the API
this fixes a large number of PHPStan errors, and also brings us a step closer to negative-build-height readiness.
This commit is contained in:
parent
42bf9578ce
commit
5b818827db
@ -46,7 +46,7 @@ final class ChunkSerializer{
|
|||||||
* Chunks are sent in a stack, so every chunk below the top non-empty one must be sent.
|
* Chunks are sent in a stack, so every chunk below the top non-empty one must be sent.
|
||||||
*/
|
*/
|
||||||
public static function getSubChunkCount(Chunk $chunk) : int{
|
public static function getSubChunkCount(Chunk $chunk) : int{
|
||||||
for($count = $chunk->getSubChunks()->count(); $count > 0; --$count){
|
for($count = count($chunk->getSubChunks()); $count > 0; --$count){
|
||||||
if($chunk->getSubChunk($count - 1)->isEmptyFast()){
|
if($chunk->getSubChunk($count - 1)->isEmptyFast()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -299,11 +299,11 @@ class Chunk{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \SplFixedArray|SubChunk[]
|
* @return SubChunk[]
|
||||||
* @phpstan-return \SplFixedArray<SubChunk>
|
* @phpstan-return array<int, SubChunk>
|
||||||
*/
|
*/
|
||||||
public function getSubChunks() : \SplFixedArray{
|
public function getSubChunks() : array{
|
||||||
return $this->subChunks;
|
return $this->subChunks->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ final class FastChunkSerializer{
|
|||||||
|
|
||||||
//subchunks
|
//subchunks
|
||||||
$subChunks = $chunk->getSubChunks();
|
$subChunks = $chunk->getSubChunks();
|
||||||
$count = $subChunks->count();
|
$count = count($subChunks);
|
||||||
$stream->putByte($count);
|
$stream->putByte($count);
|
||||||
|
|
||||||
foreach($subChunks as $y => $subChunk){
|
foreach($subChunks as $y => $subChunk){
|
||||||
|
@ -30,6 +30,7 @@ use pocketmine\world\format\SubChunk;
|
|||||||
use pocketmine\world\utils\SubChunkExplorer;
|
use pocketmine\world\utils\SubChunkExplorer;
|
||||||
use pocketmine\world\utils\SubChunkExplorerStatus;
|
use pocketmine\world\utils\SubChunkExplorerStatus;
|
||||||
use pocketmine\world\World;
|
use pocketmine\world\World;
|
||||||
|
use function count;
|
||||||
use function max;
|
use function max;
|
||||||
|
|
||||||
class SkyLightUpdate extends LightUpdate{
|
class SkyLightUpdate extends LightUpdate{
|
||||||
@ -114,7 +115,7 @@ class SkyLightUpdate extends LightUpdate{
|
|||||||
//have to avoid filling full light for any subchunk that contains a heightmap Y coordinate
|
//have to avoid filling full light for any subchunk that contains a heightmap Y coordinate
|
||||||
$highestHeightMapPlusOne = max($chunk->getHeightMapArray()) + 1;
|
$highestHeightMapPlusOne = max($chunk->getHeightMapArray()) + 1;
|
||||||
$lowestClearSubChunk = ($highestHeightMapPlusOne >> SubChunk::COORD_BIT_SIZE) + (($highestHeightMapPlusOne & SubChunk::COORD_MASK) !== 0 ? 1 : 0);
|
$lowestClearSubChunk = ($highestHeightMapPlusOne >> SubChunk::COORD_BIT_SIZE) + (($highestHeightMapPlusOne & SubChunk::COORD_MASK) !== 0 ? 1 : 0);
|
||||||
$chunkHeight = $chunk->getSubChunks()->count();
|
$chunkHeight = count($chunk->getSubChunks());
|
||||||
for($y = 0; $y < $lowestClearSubChunk && $y < $chunkHeight; $y++){
|
for($y = 0; $y < $lowestClearSubChunk && $y < $chunkHeight; $y++){
|
||||||
$chunk->getSubChunk($y)->setBlockSkyLightArray(LightArray::fill(0));
|
$chunk->getSubChunk($y)->setBlockSkyLightArray(LightArray::fill(0));
|
||||||
}
|
}
|
||||||
@ -173,7 +174,7 @@ class SkyLightUpdate extends LightUpdate{
|
|||||||
* @phpstan-param \SplFixedArray<bool> $directSkyLightBlockers
|
* @phpstan-param \SplFixedArray<bool> $directSkyLightBlockers
|
||||||
*/
|
*/
|
||||||
private static function recalculateHeightMap(Chunk $chunk, \SplFixedArray $directSkyLightBlockers) : HeightArray{
|
private static function recalculateHeightMap(Chunk $chunk, \SplFixedArray $directSkyLightBlockers) : HeightArray{
|
||||||
$maxSubChunkY = $chunk->getSubChunks()->count() - 1;
|
$maxSubChunkY = count($chunk->getSubChunks()) - 1;
|
||||||
for(; $maxSubChunkY >= 0; $maxSubChunkY--){
|
for(; $maxSubChunkY >= 0; $maxSubChunkY--){
|
||||||
if(!$chunk->getSubChunk($maxSubChunkY)->isEmptyFast()){
|
if(!$chunk->getSubChunk($maxSubChunkY)->isEmptyFast()){
|
||||||
break;
|
break;
|
||||||
|
@ -1,77 +1,17 @@
|
|||||||
parameters:
|
parameters:
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
-
|
|
||||||
message: "#^Cannot call method getFullBlock\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/World.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method isEmptyFast\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/World.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot call method collectGarbage\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
message: "#^Cannot call method collectGarbage\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/world/format/Chunk.php
|
path: ../../../src/world/format/Chunk.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method pocketmine\\\\world\\\\format\\\\Chunk\\:\\:getSubChunks\\(\\) should return array\\<int, pocketmine\\\\world\\\\format\\\\SubChunk\\> but returns array\\<int, pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\>\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/world/format/Chunk.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method pocketmine\\\\world\\\\format\\\\HeightArray\\:\\:getValues\\(\\) should return array\\<int, int\\> but returns array\\<int, int\\|null\\>\\.$#"
|
message: "#^Method pocketmine\\\\world\\\\format\\\\HeightArray\\:\\:getValues\\(\\) should return array\\<int, int\\> but returns array\\<int, int\\|null\\>\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/world/format/HeightArray.php
|
path: ../../../src/world/format/HeightArray.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getBlockLayers\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/FastChunkSerializer.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getBlockLightArray\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/FastChunkSerializer.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getBlockSkyLightArray\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/FastChunkSerializer.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getEmptyBlockId\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/FastChunkSerializer.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getBlockLayers\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/leveldb/LevelDB.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method isEmptyAuthoritative\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/leveldb/LevelDB.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getBlockLayers\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/light/BlockLightUpdate.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method setBlockLightArray\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/light/BlockLightUpdate.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$subChunk of method pocketmine\\\\world\\\\light\\\\BlockLightUpdate\\:\\:scanForLightEmittingBlocks\\(\\) expects pocketmine\\\\world\\\\format\\\\SubChunk, pocketmine\\\\world\\\\format\\\\SubChunk\\|null given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/light/BlockLightUpdate.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getBlockLightArray\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/light/LightPopulationTask.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method getBlockSkyLightArray\\(\\) on pocketmine\\\\world\\\\format\\\\SubChunk\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/light/LightPopulationTask.php
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user