From 454952228978ebfd357534586f84e53ed5f01598 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 31 Oct 2020 23:12:03 +0000 Subject: [PATCH] Rename Chunk::getSubChunkChecked() -> getSubChunk() --- src/network/mcpe/serializer/ChunkSerializer.php | 4 ++-- src/world/World.php | 4 ++-- src/world/format/Chunk.php | 12 ++++++------ src/world/generator/Flat.php | 2 +- src/world/light/LightPopulationTask.php | 4 ++-- src/world/light/SkyLightUpdate.php | 4 ++-- src/world/utils/SubChunkExplorer.php | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/network/mcpe/serializer/ChunkSerializer.php b/src/network/mcpe/serializer/ChunkSerializer.php index b661a20ea..abf0e1b25 100644 --- a/src/network/mcpe/serializer/ChunkSerializer.php +++ b/src/network/mcpe/serializer/ChunkSerializer.php @@ -43,7 +43,7 @@ final class ChunkSerializer{ */ public static function getSubChunkCount(Chunk $chunk) : int{ for($count = $chunk->getSubChunks()->count(); $count > 0; --$count){ - if($chunk->getSubChunkChecked($count - 1)->isEmptyFast()){ + if($chunk->getSubChunk($count - 1)->isEmptyFast()){ continue; } return $count; @@ -56,7 +56,7 @@ final class ChunkSerializer{ $stream = new PacketSerializer(); $subChunkCount = self::getSubChunkCount($chunk); for($y = 0; $y < $subChunkCount; ++$y){ - $layers = $chunk->getSubChunkChecked($y)->getBlockLayers(); + $layers = $chunk->getSubChunk($y)->getBlockLayers(); $stream->putByte(8); //version $stream->putByte(count($layers)); diff --git a/src/world/World.php b/src/world/World.php index ba7a4d823..a3a05d98e 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -1838,7 +1838,7 @@ class World implements ChunkManager{ return $y >= self::Y_MAX ? 15 : 0; } if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ - return $chunk->getSubChunkChecked($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); + return $chunk->getSubChunk($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); } return 0; //TODO: this should probably throw instead (light not calculated yet) } @@ -1853,7 +1853,7 @@ class World implements ChunkManager{ return 0; } if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){ - return $chunk->getSubChunkChecked($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); + return $chunk->getSubChunk($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); } return 0; //TODO: this should probably throw instead (light not calculated yet) } diff --git a/src/world/format/Chunk.php b/src/world/format/Chunk.php index 9ba58e829..c6d0fd668 100644 --- a/src/world/format/Chunk.php +++ b/src/world/format/Chunk.php @@ -145,14 +145,14 @@ class Chunk{ * @return int bitmap, (id << 4) | meta */ public function getFullBlock(int $x, int $y, int $z) : int{ - return $this->getSubChunkChecked($y >> 4)->getFullBlock($x, $y & 0x0f, $z); + return $this->getSubChunk($y >> 4)->getFullBlock($x, $y & 0x0f, $z); } /** * Sets the blockstate at the given coordinate by internal ID. */ public function setFullBlock(int $x, int $y, int $z, int $block) : void{ - $this->getSubChunkChecked($y >> 4)->setFullBlock($x, $y & 0xf, $z, $block); + $this->getSubChunk($y >> 4)->setFullBlock($x, $y & 0xf, $z, $block); $this->dirtyFlags |= self::DIRTY_FLAG_TERRAIN; } @@ -166,7 +166,7 @@ class Chunk{ */ public function getHighestBlockAt(int $x, int $z) : int{ for($y = $this->subChunks->count() - 1; $y >= 0; --$y){ - $height = $this->getSubChunkChecked($y)->getHighestBlockAt($x, $z) | ($y << 4); + $height = $this->getSubChunk($y)->getHighestBlockAt($x, $z) | ($y << 4); if($height !== -1){ return $height; } @@ -204,7 +204,7 @@ class Chunk{ public function recalculateHeightMap(\SplFixedArray $directSkyLightBlockers) : void{ $maxSubChunkY = $this->subChunks->count() - 1; for(; $maxSubChunkY >= 0; $maxSubChunkY--){ - if(!$this->getSubChunkChecked($maxSubChunkY)->isEmptyFast()){ + if(!$this->getSubChunk($maxSubChunkY)->isEmptyFast()){ break; } } @@ -217,7 +217,7 @@ class Chunk{ for($x = 0; $x < 16; ++$x){ $y = null; for($subChunkY = $maxSubChunkY; $subChunkY >= 0; $subChunkY--){ - $subHighestBlockY = $this->getSubChunkChecked($subChunkY)->getHighestBlockAt($x, $z); + $subHighestBlockY = $this->getSubChunk($subChunkY)->getHighestBlockAt($x, $z); if($subHighestBlockY !== -1){ $y = ($subChunkY * 16) + $subHighestBlockY; break; @@ -505,7 +505,7 @@ class Chunk{ $this->dirtyFlags = 0; } - public function getSubChunkChecked(int $y) : SubChunk{ + public function getSubChunk(int $y) : SubChunk{ if($y < 0 || $y >= $this->subChunks->getSize()){ throw new \InvalidArgumentException("Invalid subchunk Y coordinate $y"); } diff --git a/src/world/generator/Flat.php b/src/world/generator/Flat.php index 62dcf6590..5715ffb66 100644 --- a/src/world/generator/Flat.php +++ b/src/world/generator/Flat.php @@ -156,7 +156,7 @@ class Flat extends Generator{ $count = count($this->structure); for($sy = 0; $sy < $count; $sy += 16){ - $subchunk = $this->chunk->getSubChunkChecked($sy >> 4); + $subchunk = $this->chunk->getSubChunk($sy >> 4); for($y = 0; $y < 16 and isset($this->structure[$y | $sy]); ++$y){ $id = $this->structure[$y | $sy]; diff --git a/src/world/light/LightPopulationTask.php b/src/world/light/LightPopulationTask.php index b171d06e9..80f814cef 100644 --- a/src/world/light/LightPopulationTask.php +++ b/src/world/light/LightPopulationTask.php @@ -104,10 +104,10 @@ class LightPopulationTask extends AsyncTask{ $blockLightArrays = igbinary_unserialize($this->resultBlockLightArrays); foreach($skyLightArrays as $y => $array){ - $chunk->getSubChunkChecked($y)->setBlockSkyLightArray($array); + $chunk->getSubChunk($y)->setBlockSkyLightArray($array); } foreach($blockLightArrays as $y => $array){ - $chunk->getSubChunkChecked($y)->setBlockLightArray($array); + $chunk->getSubChunk($y)->setBlockLightArray($array); } $chunk->setLightPopulated(); } diff --git a/src/world/light/SkyLightUpdate.php b/src/world/light/SkyLightUpdate.php index d6bbdca5f..d733ce4bb 100644 --- a/src/world/light/SkyLightUpdate.php +++ b/src/world/light/SkyLightUpdate.php @@ -111,10 +111,10 @@ class SkyLightUpdate extends LightUpdate{ $lowestClearSubChunk = ($highestHeightMapPlusOne >> 4) + (($highestHeightMapPlusOne & 0xf) !== 0 ? 1 : 0); $chunkHeight = $chunk->getSubChunks()->count(); for($y = 0; $y < $lowestClearSubChunk && $y < $chunkHeight; $y++){ - $chunk->getSubChunkChecked($y)->setBlockSkyLightArray(LightArray::fill(0)); + $chunk->getSubChunk($y)->setBlockSkyLightArray(LightArray::fill(0)); } for($y = $lowestClearSubChunk, $yMax = $chunkHeight; $y < $yMax; $y++){ - $chunk->getSubChunkChecked($y)->setBlockSkyLightArray(LightArray::fill(15)); + $chunk->getSubChunk($y)->setBlockSkyLightArray(LightArray::fill(15)); } $lightSources = 0; diff --git a/src/world/utils/SubChunkExplorer.php b/src/world/utils/SubChunkExplorer.php index 69ce4d6cb..44d2c20f6 100644 --- a/src/world/utils/SubChunkExplorer.php +++ b/src/world/utils/SubChunkExplorer.php @@ -77,7 +77,7 @@ class SubChunkExplorer{ return SubChunkExplorerStatus::INVALID; } - $this->currentSubChunk = $this->currentChunk->getSubChunkChecked($y >> 4); + $this->currentSubChunk = $this->currentChunk->getSubChunk($y >> 4); if($this->onSubChunkChangeFunc !== null){ ($this->onSubChunkChangeFunc)(); }