compressionLevel = NetworkCompression::$LEVEL; $this->chunk = ChunkSerializer::serialize($chunk); $this->chunkX = $chunkX; $this->chunkZ = $chunkZ; $this->storeLocal(self::TLS_KEY_PROMISE, $promise); $this->storeLocal(self::TLS_KEY_ERROR_HOOK, $onError); } public function onRun() : void{ $this->setResult(NetworkCompression::compress(PacketBatch::fromPackets(FullChunkDataPacket::create($this->chunkX, $this->chunkZ, $this->chunk))->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()); } }