From 4e94025b3bd575b231798d481e3e64f9e6df52f6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 27 Nov 2020 13:33:25 +0000 Subject: [PATCH] SubChunk: rename defaultBlock -> emptyBlockId this better describes the purpose, which is to identify air. though, it might make more sense to make air just always have zero as air's runtime ID, since this parameter is apparently making plugin devs think that this is suitable to fill a chunk with a specific block ... --- src/world/format/SubChunk.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/world/format/SubChunk.php b/src/world/format/SubChunk.php index 5328d816a..c461f1b70 100644 --- a/src/world/format/SubChunk.php +++ b/src/world/format/SubChunk.php @@ -29,7 +29,7 @@ use function count; class SubChunk{ /** @var int */ - private $defaultBlock; + private $emptyBlockId; /** @var PalettedBlockArray[] */ private $blockLayers; @@ -43,8 +43,8 @@ class SubChunk{ * * @param PalettedBlockArray[] $blocks */ - public function __construct(int $default, array $blocks, ?LightArray $skyLight = null, ?LightArray $blockLight = null){ - $this->defaultBlock = $default; + public function __construct(int $emptyBlockId, array $blocks, ?LightArray $skyLight = null, ?LightArray $blockLight = null){ + $this->emptyBlockId = $emptyBlockId; $this->blockLayers = $blocks; $this->skyLight = $skyLight ?? LightArray::fill(15); @@ -71,14 +71,14 @@ class SubChunk{ public function getFullBlock(int $x, int $y, int $z) : int{ if(count($this->blockLayers) === 0){ - return $this->defaultBlock; + return $this->emptyBlockId; } return $this->blockLayers[0]->get($x, $y, $z); } public function setFullBlock(int $x, int $y, int $z, int $block) : void{ if(count($this->blockLayers) === 0){ - $this->blockLayers[] = new PalettedBlockArray($this->defaultBlock); + $this->blockLayers[] = new PalettedBlockArray($this->emptyBlockId); } $this->blockLayers[0]->set($x, $y, $z, $block); } @@ -95,7 +95,7 @@ class SubChunk{ return -1; } for($y = 15; $y >= 0; --$y){ - if($this->blockLayers[0]->get($x, $y, $z) !== $this->defaultBlock){ + if($this->blockLayers[0]->get($x, $y, $z) !== $this->emptyBlockId){ return $y; } } @@ -131,7 +131,7 @@ class SubChunk{ $layer->collectGarbage(); foreach($layer->getPalette() as $p){ - if($p !== $this->defaultBlock){ + if($p !== $this->emptyBlockId){ continue 2; } }