mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Mostly phase out EmptySubChunk
copy-on-write and zero-layer SubChunk objects are much easier to manage and have less cognitive overhead. obviously, the goal is to get rid of EmptySubChunk completely, but right now it does still serve a purpose (filling in dummy values for reading out-of-bounds on chunks), and that's a problem that takes a little more work to fix.
This commit is contained in:
@ -52,21 +52,13 @@ class SubChunk implements SubChunkInterface{
|
||||
$this->blockLight = $blockLight ?? new LightArray(LightArray::ZERO);
|
||||
}
|
||||
|
||||
public function isEmpty(bool $checkLight = true) : bool{
|
||||
foreach($this->blockLayers as $layer){
|
||||
$palette = $layer->getPalette();
|
||||
foreach($palette as $p){
|
||||
if($p !== $this->defaultBlock){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
(!$checkLight or (
|
||||
$this->skyLight->getData() === LightArray::FIFTEEN and
|
||||
$this->blockLight->getData() === LightArray::ZERO
|
||||
)
|
||||
);
|
||||
public function isEmptyAuthoritative() : bool{
|
||||
$this->collectGarbage();
|
||||
return $this->isEmptyFast();
|
||||
}
|
||||
|
||||
public function isEmptyFast() : bool{
|
||||
return empty($this->blockLayers);
|
||||
}
|
||||
|
||||
public function getFullBlock(int $x, int $y, int $z) : int{
|
||||
|
Reference in New Issue
Block a user