From 8cb24547ff2b3e385647ba4cfeffb6bea9231570 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 3 Mar 2019 19:02:18 +0000 Subject: [PATCH] Goodbye McRegion o/ --- .../level/format/io/region/McRegion.php | 41 ++----------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/src/pocketmine/level/format/io/region/McRegion.php b/src/pocketmine/level/format/io/region/McRegion.php index 194662a84..4059a4895 100644 --- a/src/pocketmine/level/format/io/region/McRegion.php +++ b/src/pocketmine/level/format/io/region/McRegion.php @@ -26,60 +26,25 @@ namespace pocketmine\level\format\io\region; use pocketmine\level\format\Chunk; use pocketmine\level\format\io\ChunkUtils; use pocketmine\level\format\io\exception\CorruptedChunkException; -use pocketmine\level\format\io\WritableLevelProvider; use pocketmine\level\format\SubChunk; use pocketmine\nbt\BigEndianNbtSerializer; -use pocketmine\nbt\NBT; use pocketmine\nbt\NbtDataException; use pocketmine\nbt\tag\ByteArrayTag; -use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntArrayTag; use pocketmine\nbt\tag\ListTag; use function str_repeat; use function substr; -class McRegion extends RegionLevelProvider implements WritableLevelProvider{ +class McRegion extends RegionLevelProvider{ /** * @param Chunk $chunk * * @return string + * @throws \RuntimeException */ protected function serializeChunk(Chunk $chunk) : string{ - $nbt = new CompoundTag("Level", []); - $nbt->setInt("xPos", $chunk->getX()); - $nbt->setInt("zPos", $chunk->getZ()); - - $nbt->setLong("LastUpdate", 0); //TODO - $nbt->setByte("TerrainPopulated", $chunk->isPopulated() ? 1 : 0); - $nbt->setByte("LightPopulated", 0); - - $ids = ""; - $data = ""; - $subChunks = $chunk->getSubChunks(); - for($x = 0; $x < 16; ++$x){ - for($z = 0; $z < 16; ++$z){ - for($y = 0; $y < 8; ++$y){ - $subChunk = $subChunks[$y]; - $ids .= substr($subChunk->getBlockIdArray(), ($x << 8) | ($z << 4), 16); - $data .= substr($subChunk->getBlockDataArray(), ($x << 7) | ($z << 3), 8); - } - } - } - - $nbt->setByteArray("Blocks", $ids); - $nbt->setByteArray("Data", $data); - $nbt->setByteArray("SkyLight", str_repeat("\x00", 16384)); - $nbt->setByteArray("BlockLight", str_repeat("\x00", 16384)); - - $nbt->setByteArray("Biomes", $chunk->getBiomeIdArray()); //doesn't exist in regular McRegion, this is here for PocketMine-MP only - $nbt->setByteArray("HeightMap", str_repeat("\x00", 256)); //this is ByteArray in McRegion, but IntArray in Anvil (due to raised build height) - - $nbt->setTag(new ListTag("Entities", $chunk->getNBTentities(), NBT::TAG_Compound)); - $nbt->setTag(new ListTag("TileEntities", $chunk->getNBTtiles(), NBT::TAG_Compound)); - - $writer = new BigEndianNbtSerializer(); - return $writer->writeCompressed(new CompoundTag("", [$nbt]), ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL); + throw new \RuntimeException("Unsupported"); } /**