compressionLevel = NetworkCompression::$LEVEL; $this->chunk = $chunk->networkSerialize(); $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{ $pk = new FullChunkDataPacket(); $pk->chunkX = $this->chunkX; $pk->chunkZ = $this->chunkZ; $pk->data = $this->chunk; $this->setResult(NetworkCompression::compress(PacketBatch::fromPackets($pk)->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()); } }