mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 07:09:56 +00:00
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 ...
This commit is contained in:
parent
4d42f0c3db
commit
4e94025b3b
@ -29,7 +29,7 @@ use function count;
|
|||||||
|
|
||||||
class SubChunk{
|
class SubChunk{
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $defaultBlock;
|
private $emptyBlockId;
|
||||||
/** @var PalettedBlockArray[] */
|
/** @var PalettedBlockArray[] */
|
||||||
private $blockLayers;
|
private $blockLayers;
|
||||||
|
|
||||||
@ -43,8 +43,8 @@ class SubChunk{
|
|||||||
*
|
*
|
||||||
* @param PalettedBlockArray[] $blocks
|
* @param PalettedBlockArray[] $blocks
|
||||||
*/
|
*/
|
||||||
public function __construct(int $default, array $blocks, ?LightArray $skyLight = null, ?LightArray $blockLight = null){
|
public function __construct(int $emptyBlockId, array $blocks, ?LightArray $skyLight = null, ?LightArray $blockLight = null){
|
||||||
$this->defaultBlock = $default;
|
$this->emptyBlockId = $emptyBlockId;
|
||||||
$this->blockLayers = $blocks;
|
$this->blockLayers = $blocks;
|
||||||
|
|
||||||
$this->skyLight = $skyLight ?? LightArray::fill(15);
|
$this->skyLight = $skyLight ?? LightArray::fill(15);
|
||||||
@ -71,14 +71,14 @@ class SubChunk{
|
|||||||
|
|
||||||
public function getFullBlock(int $x, int $y, int $z) : int{
|
public function getFullBlock(int $x, int $y, int $z) : int{
|
||||||
if(count($this->blockLayers) === 0){
|
if(count($this->blockLayers) === 0){
|
||||||
return $this->defaultBlock;
|
return $this->emptyBlockId;
|
||||||
}
|
}
|
||||||
return $this->blockLayers[0]->get($x, $y, $z);
|
return $this->blockLayers[0]->get($x, $y, $z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFullBlock(int $x, int $y, int $z, int $block) : void{
|
public function setFullBlock(int $x, int $y, int $z, int $block) : void{
|
||||||
if(count($this->blockLayers) === 0){
|
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);
|
$this->blockLayers[0]->set($x, $y, $z, $block);
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ class SubChunk{
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for($y = 15; $y >= 0; --$y){
|
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;
|
return $y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ class SubChunk{
|
|||||||
$layer->collectGarbage();
|
$layer->collectGarbage();
|
||||||
|
|
||||||
foreach($layer->getPalette() as $p){
|
foreach($layer->getPalette() as $p){
|
||||||
if($p !== $this->defaultBlock){
|
if($p !== $this->emptyBlockId){
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user