World::setBiomeId() now bails when trying to modify a non-generated chunk (or chunk locked for generation)

This commit is contained in:
Dylan K. Taylor 2020-11-01 14:59:22 +00:00
parent 3e21e47b7a
commit 11434f3a27
2 changed files with 12 additions and 6 deletions

View File

@ -1869,7 +1869,18 @@ class World implements ChunkManager{
}
public function setBiomeId(int $x, int $z, int $biomeId) : void{
$this->getOrLoadChunk($x >> 4, $z >> 4, true)->setBiomeId($x & 0x0f, $z & 0x0f, $biomeId);
$chunkX = $x >> 4;
$chunkZ = $z >> 4;
if($this->isChunkLocked($chunkX, $chunkZ)){
//the changes would be overwritten when the generation finishes
throw new WorldException("Chunk is currently locked for async generation/population");
}
if(($chunk = $this->getOrLoadChunk($chunkX, $chunkZ, false)) !== null){
$chunk->setBiomeId($x & 0x0f, $z & 0x0f, $biomeId);
}else{
//if we allowed this, the modifications would be lost when the chunk is created
throw new WorldException("Cannot set biome in a non-generated chunk");
}
}
/**

View File

@ -535,11 +535,6 @@ parameters:
count: 3
path: ../../../src/world/World.php
-
message: "#^Cannot call method setBiomeId\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
count: 1
path: ../../../src/world/World.php
-
message: "#^Cannot call method isPopulated\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
count: 1