getSafeSpawn will return default y if no solid blocks were found below

This commit is contained in:
GameHerobrine 2024-11-25 10:05:16 +03:00
parent 2091dd1a98
commit 61ee4ab335

View file

@ -821,7 +821,7 @@ class Level{
}
if($spawn instanceof Vector3){
$x = (int) round($spawn->x);
$y = (int) round($spawn->y);
$fy = $y = (int) round($spawn->y);
$z = (int) round($spawn->z);
if($x < 0 || $x > 255 || $z < 0 || $z > 255){
return new Position($x, 128, $z, $this);
@ -835,6 +835,9 @@ class Level{
break;
}
}
if($y == 0){
return new Position($x, $fy, $z, $this); //force tp to default if pos is empty
}
for(; $y < 128; ++$y){
$v = new Vector3($x, $y, $z);
if($this->getBlock($v->getSide(1)) instanceof AirBlock){