Use Chunk::getSubChunkChecked() in places where we know that an invalid coordinate cannot be requested

This commit is contained in:
Dylan K. Taylor
2020-10-31 22:48:41 +00:00
parent b270029161
commit 01001dca74
3 changed files with 6 additions and 9 deletions

View File

@ -43,7 +43,7 @@ final class ChunkSerializer{
*/
public static function getSubChunkCount(Chunk $chunk) : int{
for($count = $chunk->getSubChunks()->count(); $count > 0; --$count){
if($chunk->getSubChunk($count - 1)->isEmptyFast()){
if($chunk->getSubChunkChecked($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->getSubChunk($y)->getBlockLayers();
$layers = $chunk->getSubChunkChecked($y)->getBlockLayers();
$stream->putByte(8); //version
$stream->putByte(count($layers));