compressionLevel = Zlib::$LEVEL; $this->chunk = FastChunkSerializer::serialize($chunk); $this->chunkX = $chunkX; $this->chunkZ = $chunkZ; $this->tiles = ChunkSerializer::serializeTiles($chunk); $this->storeLocal(self::TLS_KEY_PROMISE, $promise); $this->storeLocal(self::TLS_KEY_ERROR_HOOK, $onError); } public function onRun() : void{ $chunk = FastChunkSerializer::deserialize($this->chunk); $subCount = ChunkSerializer::getSubChunkCount($chunk); $payload = ChunkSerializer::serialize($chunk, $this->tiles); $this->setResult(Zlib::compress(PacketBatch::fromPackets(LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $subCount, $payload))->getBuffer(), $this->compressionLevel)); } public function onError() : void{ /** @var \Closure $hook */ $hook = $this->fetchLocal(self::TLS_KEY_ERROR_HOOK); if($hook !== null){ $hook(); } } public function onCompletion() : void{ /** @var CompressBatchPromise $promise */ $promise = $this->fetchLocal(self::TLS_KEY_PROMISE); $promise->resolve($this->getResult()); } }