mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Avoid usage of for-loop vars outside of for-loop context
these problems were reported by PHPStan strict rules. They aren't actually bugs, but they could become bugs in the future.
This commit is contained in:
@ -47,7 +47,8 @@ class GroundCover extends Populator{
|
||||
}
|
||||
|
||||
$column = $chunk->getBlockIdColumn($x, $z);
|
||||
for($y = 127; $y > 0; --$y){
|
||||
$y = 127;
|
||||
for(; $y > 0; --$y){
|
||||
if($column[$y] !== "\x00" and !BlockFactory::get(ord($column[$y]))->isTransparent()){
|
||||
break;
|
||||
}
|
||||
|
@ -77,10 +77,10 @@ class TallGrass extends Populator{
|
||||
for($y = 127; $y >= 0; --$y){
|
||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||
if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER){
|
||||
break;
|
||||
return $y + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $y === 0 ? -1 : ++$y;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ class Tree extends Populator{
|
||||
for($y = 127; $y > 0; --$y){
|
||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||
if($b === Block::DIRT or $b === Block::GRASS){
|
||||
break;
|
||||
return $y + 1;
|
||||
}elseif($b !== Block::AIR and $b !== Block::SNOW_LAYER){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return ++$y;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user