compressionLevel = NetworkCompression::$LEVEL; $this->chunk = $chunk->fastSerialize(); $this->chunkX = $chunkX; $this->chunkZ = $chunkZ; //TODO: serialize tiles with chunks $tiles = ""; foreach($chunk->getTiles() as $tile){ if($tile instanceof Spawnable){ $tiles .= $tile->getSerializedSpawnCompound(); } } $this->tiles = $tiles; $this->storeLocal($promise); } public function onRun() : void{ $chunk = Chunk::fastDeserialize($this->chunk); $pk = new FullChunkDataPacket(); $pk->chunkX = $this->chunkX; $pk->chunkZ = $this->chunkZ; $pk->data = $chunk->networkSerialize() . $this->tiles; $stream = new PacketStream(); $stream->putPacket($pk); $this->setResult(NetworkCompression::compress($stream->buffer, $this->compressionLevel), false); } public function onCompletion() : void{ /** @var CompressBatchPromise $promise */ $promise = $this->fetchLocal(); $promise->resolve($this->getResult()); } }