region: harden handling of ByteArrayTag

previously this would just explode if the wrong length of data was given.
This commit is contained in:
Dylan K. Taylor
2020-10-31 15:37:06 +00:00
parent 058bb3a91a
commit 0cbc5c9a4a
4 changed files with 24 additions and 5 deletions

View File

@ -36,7 +36,10 @@ class PMAnvil extends RegionWorldProvider{
use LegacyAnvilChunkTrait;
protected function deserializeSubChunk(CompoundTag $subChunk) : SubChunk{
return new SubChunk(BlockLegacyIds::AIR << 4, [SubChunkConverter::convertSubChunkXZY($subChunk->getByteArray("Blocks"), $subChunk->getByteArray("Data"))]);
return new SubChunk(BlockLegacyIds::AIR << 4, [SubChunkConverter::convertSubChunkXZY(
self::readFixedSizeByteArray($subChunk, "Blocks", 4096),
self::readFixedSizeByteArray($subChunk, "Data", 2048)
)]);
}
protected static function getRegionFileExtension() : string{