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:
@ -26,8 +26,7 @@ namespace pocketmine\world\utils;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\ChunkManager;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\EmptySubChunk;
|
||||
use pocketmine\world\format\SubChunkInterface;
|
||||
use pocketmine\world\format\SubChunk;
|
||||
|
||||
class SubChunkIteratorManager{
|
||||
/** @var ChunkManager */
|
||||
@ -35,7 +34,7 @@ class SubChunkIteratorManager{
|
||||
|
||||
/** @var Chunk|null */
|
||||
public $currentChunk;
|
||||
/** @var SubChunkInterface|null */
|
||||
/** @var SubChunk|null */
|
||||
public $currentSubChunk;
|
||||
|
||||
/** @var int */
|
||||
@ -67,11 +66,12 @@ class SubChunkIteratorManager{
|
||||
if($this->currentSubChunk === null or $this->currentY !== ($y >> 4)){
|
||||
$this->currentY = $y >> 4;
|
||||
|
||||
$this->currentSubChunk = $this->currentChunk->getSubChunk($y >> 4, $create);
|
||||
if($this->currentSubChunk instanceof EmptySubChunk){
|
||||
if($this->currentY < 0 or $this->currentY >= $this->currentChunk->getHeight()){
|
||||
$this->currentSubChunk = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->currentSubChunk = $this->currentChunk->getSubChunk($y >> 4);
|
||||
if($this->onSubChunkChangeFunc !== null){
|
||||
($this->onSubChunkChangeFunc)();
|
||||
}
|
||||
|
Reference in New Issue
Block a user