pocketmine\level\format\mcregion\Chunk::toBinary PHP Метод

toBinary() публичный Метод

public toBinary ( )
    public function toBinary()
    {
        $nbt = clone $this->getNBT();
        $nbt->xPos = new IntTag("xPos", $this->x);
        $nbt->zPos = new IntTag("zPos", $this->z);
        if ($this->isGenerated()) {
            $nbt->Blocks = new ByteArrayTag("Blocks", $this->getBlockIdArray());
            $nbt->Data = new ByteArrayTag("Data", $this->getBlockDataArray());
            $nbt->SkyLight = new ByteArrayTag("SkyLight", $this->getBlockSkyLightArray());
            $nbt->BlockLight = new ByteArrayTag("BlockLight", $this->getBlockLightArray());
            $nbt->BiomeColors = new IntArrayTag("BiomeColors", $this->getBiomeColorArray());
            $nbt->HeightMap = new IntArrayTag("HeightMap", $this->getHeightMapArray());
        }
        $entities = [];
        foreach ($this->getEntities() as $entity) {
            if (!$entity instanceof Player and !$entity->closed) {
                $entity->saveNBT();
                $entities[] = $entity->namedtag;
            }
        }
        $nbt->Entities = new ListTag("Entities", $entities);
        $nbt->Entities->setTagType(NBT::TAG_Compound);
        $tiles = [];
        foreach ($this->getTiles() as $tile) {
            $tile->saveNBT();
            $tiles[] = $tile->namedtag;
        }
        $nbt->TileEntities = new ListTag("TileEntities", $tiles);
        $nbt->TileEntities->setTagType(NBT::TAG_Compound);
        $extraData = new BinaryStream();
        $extraData->putInt(count($this->getBlockExtraDataArray()));
        foreach ($this->getBlockExtraDataArray() as $key => $value) {
            $extraData->putInt($key);
            $extraData->putShort($value);
        }
        $nbt->ExtraData = new ByteArrayTag("ExtraData", $extraData->getBuffer());
        $writer = new NBT(NBT::BIG_ENDIAN);
        $nbt->setName("Level");
        $writer->setData(new CompoundTag("", ["Level" => $nbt]));
        return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
    }