Replace hardcoded block metadata shifts and masks with constants

we might want to make these bigger than 4 bits in the future.
This commit is contained in:
Dylan K. Taylor
2021-06-16 12:48:09 +01:00
parent c22f793521
commit 61c59be299
9 changed files with 37 additions and 29 deletions

View File

@ -26,6 +26,7 @@ declare(strict_types=1);
namespace pocketmine\world\format;
use pocketmine\block\Block;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\tile\Tile;
use pocketmine\data\bedrock\BiomeIds;
@ -86,7 +87,7 @@ class Chunk{
$this->subChunks = new \SplFixedArray(Chunk::MAX_SUBCHUNKS);
foreach($this->subChunks as $y => $null){
$this->subChunks[$y] = $subChunks[$y] ?? new SubChunk(BlockLegacyIds::AIR << 4, []);
$this->subChunks[$y] = $subChunks[$y] ?? new SubChunk(BlockLegacyIds::AIR << Block::INTERNAL_METADATA_BITS, []);
}
$val = ($this->subChunks->getSize() * 16);
@ -366,7 +367,7 @@ class Chunk{
throw new \InvalidArgumentException("Invalid subchunk Y coordinate $y");
}
$this->subChunks[$y] = $subChunk ?? new SubChunk(BlockLegacyIds::AIR << 4, []);
$this->subChunks[$y] = $subChunk ?? new SubChunk(BlockLegacyIds::AIR << Block::INTERNAL_METADATA_BITS, []);
$this->setDirtyFlag(self::DIRTY_FLAG_TERRAIN, true);
}