22declare(strict_types=1);
24namespace pocketmine\world\light;
30use pocketmine\world\format\LightArray;
34use
function igbinary_serialize;
35use
function igbinary_unserialize;
38 private const TLS_KEY_COMPLETION_CALLBACK =
"onCompletion";
42 private string $resultHeightMap;
43 private string $resultSkyLightArrays;
44 private string $resultBlockLightArrays;
51 $this->
storeLocal(self::TLS_KEY_COMPLETION_CALLBACK, $onCompletion);
58 $manager->setChunk(0, 0, $chunk);
60 $blockFactory = RuntimeBlockStateRegistry::getInstance();
64 ] as $name => $update){
65 $update->recalculateChunk(0, 0);
69 $chunk->setLightPopulated();
71 $this->resultHeightMap = igbinary_serialize($chunk->getHeightMapArray());
73 $blockLightArrays = [];
74 foreach($chunk->getSubChunks() as $y => $subChunk){
75 $skyLightArrays[$y] = $subChunk->getBlockSkyLightArray();
76 $blockLightArrays[$y] = $subChunk->getBlockLightArray();
78 $this->resultSkyLightArrays = igbinary_serialize($skyLightArrays);
79 $this->resultBlockLightArrays = igbinary_serialize($blockLightArrays);
84 $heightMapArray = igbinary_unserialize($this->resultHeightMap);
87 $skyLightArrays = igbinary_unserialize($this->resultSkyLightArrays);
89 $blockLightArrays = igbinary_unserialize($this->resultBlockLightArrays);
95 $callback = $this->fetchLocal(self::TLS_KEY_COMPLETION_CALLBACK);
96 $callback($blockLightArrays, $skyLightArrays, $heightMapArray);
storeLocal(string $key, mixed $complexData)
__construct(Chunk $chunk, \Closure $onCompletion)