From 61ee4ab335c2787b30303ce8db9a289948c70370 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Mon, 25 Nov 2024 10:05:16 +0300 Subject: [PATCH] getSafeSpawn will return default y if no solid blocks were found below --- src/world/Level.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/world/Level.php b/src/world/Level.php index 34efba44..aa249000 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -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){