fixed overoptimized code in getSafeSpawn(), close #1248

This commit is contained in:
Dylan K. Taylor 2017-11-17 13:57:33 +00:00
parent 28188e5ef4
commit 5178373d8a

View File

@ -2709,9 +2709,7 @@ class Level implements ChunkManager, Metadatable{
$y = (int) min($max - 2, $v->y);
$wasAir = ($chunk->getBlockId($x, $y - 1, $z) === 0);
for(; $y > 0; --$y){
$b = $chunk->getFullBlock($x, $y, $z);
$block = BlockFactory::get($b >> 4, $b & 0x0f);
if($this->isFullBlock($block)){
if($this->isFullBlock($this->getBlockAt($x, $y, $z))){
if($wasAir){
$y++;
break;
@ -2722,12 +2720,8 @@ class Level implements ChunkManager, Metadatable{
}
for(; $y >= 0 and $y < $max; ++$y){
$b = $chunk->getFullBlock($x, $y + 1, $z);
$block = BlockFactory::get($b >> 4, $b & 0x0f);
if(!$this->isFullBlock($block)){
$b = $chunk->getFullBlock($x, $y, $z);
$block = BlockFactory::get($b >> 4, $b & 0x0f);
if(!$this->isFullBlock($block)){
if(!$this->isFullBlock($this->getBlockAt($x, $y + 1, $z))){
if(!$this->isFullBlock($this->getBlockAt($x, $y, $z))){
return new Position($spawn->x, $y === (int) $spawn->y ? $spawn->y : $y, $spawn->z, $this);
}
}else{