mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-19 04:05:31 +00:00
Level::getSafeSpawn() look for solid block
This commit is contained in:
parent
c8dd85de75
commit
fb2bcdb722
@ -415,11 +415,20 @@ class Level{
|
||||
return new Position($this->level->getData("spawnX"), $this->level->getData("spawnY"), $this->level->getData("spawnZ"), $this);
|
||||
}
|
||||
|
||||
public function getSafeSpawn(){
|
||||
if(($spawn = $this->getSpawn()) !== false){
|
||||
public function getSafeSpawn($spawn = false){
|
||||
if($spawn === false){
|
||||
$spawn = $this->getSpawn();
|
||||
}
|
||||
if($spawn instanceof Vector3){
|
||||
$x = (int) round($spawn->x);
|
||||
$y = (int) round($spawn->y);
|
||||
$z = (int) round($spawn->z);
|
||||
for(; $y > 0; --$y){
|
||||
$v = new Vector3($x, $y, $z);
|
||||
if(!($this->getBlock($v->getSide(0)) instanceof AirBlock)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(; $y < 128; ++$y){
|
||||
$v = new Vector3($x, $y, $z);
|
||||
if($this->getBlock($v->getSide(1)) instanceof AirBlock){
|
||||
|
Loading…
x
Reference in New Issue
Block a user