Added __clone() for Chunk and SubChunk

we need this because the flatworld generator uses clone to produce new chunks, so we don't want the chunks getting fucked up.
This commit is contained in:
Dylan K. Taylor
2020-11-01 16:14:25 +00:00
parent 1d551af54a
commit 315962c12c
4 changed files with 114 additions and 0 deletions

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\format;
use function array_map;
use function array_values;
use function count;
@ -141,4 +142,13 @@ class SubChunk{
$this->skyLight->collectGarbage();
$this->blockLight->collectGarbage();
}
public function __clone(){
$this->blockLayers = array_map(function(PalettedBlockArray $array) : PalettedBlockArray{
return clone $array;
}, $this->blockLayers);
$this->skyLight = clone $this->skyLight;
$this->blockLight = clone $this->blockLight;
}
}