compressor = $compressor; $this->chunk = FastChunkSerializer::serializeWithoutLight($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, RuntimeBlockMapping::getInstance(), $this->tiles); $this->setResult($this->compressor->compress(PacketBatch::fromPackets(LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $subCount, $payload))->getBuffer())); } public function onError() : void{ /** * @var \Closure|null $hook * @phpstan-var (\Closure() : void)|null $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()); } }