diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 430dee8db..41de5a65a 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -411,8 +411,8 @@ class Chunk{ * @return int New calculated heightmap value (0-256 inclusive) */ public function recalculateHeightMapColumn(int $x, int $z) : int{ - $max = $this->getHighestBlockAt($x, $z); - for($y = $max; $y >= 0; --$y){ + $y = $this->getHighestBlockAt($x, $z); + for(; $y >= 0; --$y){ if(BlockFactory::$lightFilter[$id = $this->getBlockId($x, $y, $z)] > 1 or BlockFactory::$diffusesSkyLight[$id]){ break; } @@ -438,9 +438,9 @@ class Chunk{ for($x = 0; $x < 16; ++$x){ for($z = 0; $z < 16; ++$z){ + $y = $maxY; $heightMap = $this->getHeightMap($x, $z); - - for($y = $maxY; $y >= $heightMap; --$y){ + for(; $y >= $heightMap; --$y){ $this->setBlockSkyLight($x, $y, $z, 15); } @@ -805,10 +805,10 @@ class Chunk{ //No need to thoroughly prune empties at runtime, this will just reduce performance. continue; } - break; + return $y; } - return $y; + return -1; } /** diff --git a/src/pocketmine/level/generator/populator/GroundCover.php b/src/pocketmine/level/generator/populator/GroundCover.php index 5961a5487..08cd1c5d2 100644 --- a/src/pocketmine/level/generator/populator/GroundCover.php +++ b/src/pocketmine/level/generator/populator/GroundCover.php @@ -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; } diff --git a/src/pocketmine/level/generator/populator/TallGrass.php b/src/pocketmine/level/generator/populator/TallGrass.php index 020fb9a11..73f8e1f63 100644 --- a/src/pocketmine/level/generator/populator/TallGrass.php +++ b/src/pocketmine/level/generator/populator/TallGrass.php @@ -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; } } diff --git a/src/pocketmine/level/generator/populator/Tree.php b/src/pocketmine/level/generator/populator/Tree.php index c5a44fad7..16f73578d 100644 --- a/src/pocketmine/level/generator/populator/Tree.php +++ b/src/pocketmine/level/generator/populator/Tree.php @@ -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; } } diff --git a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php index ca92a9f4f..ab5e8df2e 100644 --- a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php +++ b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php @@ -287,7 +287,8 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ if($quoteType === null){ $quoteType = $raw[$i]; }elseif($raw[$i] === $quoteType){ - for($backslashes = 0; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){} + $backslashes = 0; + for(; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){} if(($backslashes % 2) === 0){ //unescaped quote $quoteType = null; }