mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Chunk: Share EmptySubChunk instance with other chunks on the same thread
This commit is contained in:
parent
0d177d5219
commit
857f6dd5df
@ -103,7 +103,7 @@ class Chunk{
|
||||
$this->height = Chunk::MAX_SUBCHUNKS; //TODO: add a way of changing this
|
||||
|
||||
$this->subChunks = new \SplFixedArray($this->height);
|
||||
$this->emptySubChunk = new EmptySubChunk();
|
||||
$this->emptySubChunk = EmptySubChunk::getInstance();
|
||||
|
||||
foreach($this->subChunks as $y => $null){
|
||||
$this->subChunks[$y] = $subChunks[$y] ?? $this->emptySubChunk;
|
||||
|
@ -24,6 +24,16 @@ declare(strict_types=1);
|
||||
namespace pocketmine\level\format;
|
||||
|
||||
class EmptySubChunk implements SubChunkInterface{
|
||||
/** @var EmptySubChunk */
|
||||
private static $instance;
|
||||
|
||||
public static function getInstance() : self{
|
||||
if(self::$instance === null){
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function isEmpty(bool $checkLight = true) : bool{
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user