World: formalize setBlockAt()'s refusal to modify un-generated chunks

closes #2631
This commit is contained in:
Dylan K. Taylor 2020-11-01 17:24:09 +00:00
parent b7690fed04
commit 0bb37b5065

View File

@ -1401,6 +1401,14 @@ class World implements ChunkManager{
if(!$this->isInWorld($x, $y, $z)){
throw new \InvalidArgumentException("Pos x=$x,y=$y,z=$z is outside of the world bounds");
}
$chunkX = $x >> 4;
$chunkZ = $z >> 4;
if($this->isChunkLocked($chunkX, $chunkZ)){
throw new WorldException("Terrain is locked for generation/population");
}
if(!$this->loadChunk($chunkX, $chunkZ, false)){ //current expected behaviour is to try to load the terrain synchronously
throw new WorldException("Cannot set a block in un-generated terrain");
}
$this->timings->setBlock->startTiming();