42 private array $lightEmitters
44 parent::__construct($subChunkExplorer, $lightFilters);
47 protected function getCurrentLightArray() : LightArray{
48 return $this->subChunkExplorer->currentSubChunk->getBlockLightArray();
51 public function recalculateNode(
int $x,
int $y,
int $z) : void{
53 $block = $this->subChunkExplorer->currentSubChunk->getBlockStateId($x & SubChunk::COORD_MASK, $y & SubChunk::COORD_MASK, $z & SubChunk::COORD_MASK);
54 $this->setAndUpdateLight($x, $y, $z, max($this->lightEmitters[$block] ?? 0, $this->getHighestAdjacentLight($x, $y, $z) - ($this->lightFilters[$block] ?? self::BASE_LIGHT_FILTER)));
60 throw new \InvalidArgumentException(
"Chunk $chunkX $chunkZ does not exist");
62 $chunk = $this->subChunkExplorer->currentChunk;
65 foreach($chunk->getSubChunks() as $subChunkY => $subChunk){
66 $subChunk->setBlockLightArray(LightArray::fill(0));
68 foreach($subChunk->getBlockLayers() as $layer){
69 foreach($layer->getPalette() as $state){
70 if(($this->lightEmitters[$state] ?? 0) > 0){
71 $lightSources += $this->scanForLightEmittingBlocks($subChunk, $chunkX << SubChunk::COORD_BIT_SIZE, $subChunkY << SubChunk::COORD_BIT_SIZE, $chunkZ << SubChunk::COORD_BIT_SIZE);
81 private function scanForLightEmittingBlocks(SubChunk $subChunk,
int $baseX,
int $baseY,
int $baseZ) : int{
83 for($x = 0; $x < SubChunk::EDGE_LENGTH; ++$x){
84 for($z = 0; $z < SubChunk::EDGE_LENGTH; ++$z){
85 for($y = 0; $y < SubChunk::EDGE_LENGTH; ++$y){
86 $light = $this->lightEmitters[$subChunk->getBlockStateId($x, $y, $z)] ?? 0;
88 $this->setAndUpdateLight(