From 8a062f440df4cb70b59b774f1ada07f76bd3534e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 3 Oct 2018 18:35:39 +0100 Subject: [PATCH] Chunk: remove column methods these were (mostly) unused, and the places they were used breaks the interface definitions. It also exposes internals that are sensitive to change. --- src/pocketmine/level/format/Chunk.php | 60 ------------------- .../level/generator/populator/GroundCover.php | 10 ++-- 2 files changed, 6 insertions(+), 64 deletions(-) diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 1cdd00561..01835e32d 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -461,66 +461,6 @@ class Chunk{ $this->biomeIds{($z << 4) | $x} = chr($biomeId & 0xff); } - /** - * Returns a column of block IDs from bottom to top at the specified X/Z chunk block coordinates. - * @param int $x 0-15 - * @param int $z 0-15 - * - * @return string - */ - public function getBlockIdColumn(int $x, int $z) : string{ - $result = ""; - foreach($this->subChunks as $subChunk){ - $result .= $subChunk->getBlockIdColumn($x, $z); - } - return $result; - } - - /** - * Returns a column of block meta values from bottom to top at the specified X/Z chunk block coordinates. - * @param int $x 0-15 - * @param int $z 0-15 - * - * @return string - */ - public function getBlockDataColumn(int $x, int $z) : string{ - $result = ""; - foreach($this->subChunks as $subChunk){ - $result .= $subChunk->getBlockDataColumn($x, $z); - } - return $result; - } - - /** - * Returns a column of sky light values from bottom to top at the specified X/Z chunk block coordinates. - * @param int $x 0-15 - * @param int $z 0-15 - * - * @return string - */ - public function getBlockSkyLightColumn(int $x, int $z) : string{ - $result = ""; - foreach($this->subChunks as $subChunk){ - $result .= $subChunk->getBlockSkyLightColumn($x, $z); - } - return $result; - } - - /** - * Returns a column of block light values from bottom to top at the specified X/Z chunk block coordinates. - * @param int $x 0-15 - * @param int $z 0-15 - * - * @return string - */ - public function getBlockLightColumn(int $x, int $z) : string{ - $result = ""; - foreach($this->subChunks as $subChunk){ - $result .= $subChunk->getBlockLightColumn($x, $z); - } - return $result; - } - /** * @return bool */ diff --git a/src/pocketmine/level/generator/populator/GroundCover.php b/src/pocketmine/level/generator/populator/GroundCover.php index 1410beb0a..1218b449a 100644 --- a/src/pocketmine/level/generator/populator/GroundCover.php +++ b/src/pocketmine/level/generator/populator/GroundCover.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\level\generator\populator; +use pocketmine\block\Block; use pocketmine\block\BlockFactory; use pocketmine\block\Liquid; use pocketmine\level\biome\Biome; @@ -43,9 +44,9 @@ class GroundCover extends Populator{ $diffY = 1; } - $column = $chunk->getBlockIdColumn($x, $z); for($y = 127; $y > 0; --$y){ - if($column{$y} !== "\x00" and !BlockFactory::get(ord($column{$y}))->isTransparent()){ + $id = $chunk->getBlockId($x, $y, $z); + if($id !== Block::AIR and !BlockFactory::get($id)->isTransparent()){ break; } } @@ -53,10 +54,11 @@ class GroundCover extends Populator{ $endY = $startY - count($cover); for($y = $startY; $y > $endY and $y >= 0; --$y){ $b = $cover[$startY - $y]; - if($column{$y} === "\x00" and $b->isSolid()){ + $id = $chunk->getBlockId($x, $y, $z); + if($id === Block::AIR and $b->isSolid()){ break; } - if($b->canBeFlowedInto() and BlockFactory::get(ord($column{$y})) instanceof Liquid){ + if($b->canBeFlowedInto() and BlockFactory::get($id) instanceof Liquid){ continue; } if($b->getDamage() === 0){