mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Chunks no longer exist in un-generated state
a non-generated chunk is now always represented by NULL. This forces the case of ungenerated chunks to be handled by all code, which is necessary because ungenerated chunks cannot be interacted with or modified in any meaningful way.
This commit is contained in:
@ -146,7 +146,6 @@ class Flat extends Generator{
|
||||
|
||||
protected function generateBaseChunk() : void{
|
||||
$this->chunk = new Chunk();
|
||||
$this->chunk->setGenerated();
|
||||
|
||||
for($Z = 0; $Z < 16; ++$Z){
|
||||
for($X = 0; $X < 16; ++$X){
|
||||
|
@ -91,7 +91,7 @@ class PopulationTask extends AsyncTask{
|
||||
/** @var Chunk[] $chunks */
|
||||
$chunks = [];
|
||||
|
||||
$chunk = $this->chunk !== null ? FastChunkSerializer::deserialize($this->chunk) : new Chunk();
|
||||
$chunk = $this->chunk !== null ? FastChunkSerializer::deserialize($this->chunk) : null;
|
||||
|
||||
for($i = 0; $i < 9; ++$i){
|
||||
if($i === 4){
|
||||
@ -99,27 +99,29 @@ class PopulationTask extends AsyncTask{
|
||||
}
|
||||
$ck = $this->{"chunk$i"};
|
||||
if($ck === null){
|
||||
$chunks[$i] = new Chunk();
|
||||
$chunks[$i] = null;
|
||||
}else{
|
||||
$chunks[$i] = FastChunkSerializer::deserialize($ck);
|
||||
}
|
||||
}
|
||||
|
||||
$manager->setChunk($this->chunkX, $this->chunkZ, $chunk);
|
||||
if(!$chunk->isGenerated()){
|
||||
if($chunk === null){
|
||||
$generator->generateChunk($manager, $this->chunkX, $this->chunkZ);
|
||||
$chunk = $manager->getChunk($this->chunkX, $this->chunkZ);
|
||||
$chunk->setGenerated();
|
||||
$chunk->setDirtyFlag(Chunk::DIRTY_FLAG_TERRAIN, true);
|
||||
$chunk->setDirtyFlag(Chunk::DIRTY_FLAG_BIOMES, true);
|
||||
}
|
||||
|
||||
foreach($chunks as $i => $c){
|
||||
$cX = (-1 + $i % 3) + $this->chunkX;
|
||||
$cZ = (-1 + intdiv($i, 3)) + $this->chunkZ;
|
||||
$manager->setChunk($cX, $cZ, $c);
|
||||
if(!$c->isGenerated()){
|
||||
if($c === null){
|
||||
$generator->generateChunk($manager, $cX, $cZ);
|
||||
$chunks[$i] = $manager->getChunk($cX, $cZ);
|
||||
$chunks[$i]->setGenerated();
|
||||
$chunks[$i]->setDirtyFlag(Chunk::DIRTY_FLAG_TERRAIN, true);
|
||||
$chunks[$i]->setDirtyFlag(Chunk::DIRTY_FLAG_BIOMES, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user