Level: Make getSafeSpawn() account for non-generated chunks

fixes #2295

There is still an issue in that the spawn point will not be offset if the chunk is not generated, but this is better than the spawn point being down at y=0. The other issue is a job for another time.
This commit is contained in:
Dylan K. Taylor 2018-07-11 10:17:59 +01:00
parent b3ffce9729
commit 06b80a9536

View File

@ -2791,7 +2791,7 @@ class Level implements ChunkManager, Metadatable{
$chunk = $this->getChunk($v->x >> 4, $v->z >> 4, false); $chunk = $this->getChunk($v->x >> 4, $v->z >> 4, false);
$x = (int) $v->x; $x = (int) $v->x;
$z = (int) $v->z; $z = (int) $v->z;
if($chunk !== null){ if($chunk !== null and $chunk->isGenerated()){
$y = (int) min($max - 2, $v->y); $y = (int) min($max - 2, $v->y);
$wasAir = ($chunk->getBlockId($x & 0x0f, $y - 1, $z & 0x0f) === 0); $wasAir = ($chunk->getBlockId($x & 0x0f, $y - 1, $z & 0x0f) === 0);
for(; $y > 0; --$y){ for(; $y > 0; --$y){