Implement glow lichen (#5401)

This commit is contained in:
IvanCraft623
2023-06-04 10:04:08 -05:00
committed by GitHub
parent 9c6d4093ae
commit 6d7f44d8fe
14 changed files with 384 additions and 6 deletions

View File

@ -29,6 +29,7 @@ use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\SlabType;
use pocketmine\block\utils\WallConnectionType;
use pocketmine\block\utils\WoodType;
use pocketmine\data\bedrock\block\BlockLegacyMetadata;
use pocketmine\data\bedrock\block\BlockStateData;
use pocketmine\data\bedrock\block\BlockStateNames;
use pocketmine\data\bedrock\block\BlockStateSerializeException;
@ -39,6 +40,7 @@ use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\nbt\tag\Tag;
use pocketmine\utils\AssumptionFailedError;
final class BlockStateWriter{
@ -88,6 +90,28 @@ final class BlockStateWriter{
return $this;
}
/**
* @param int[] $faces
* @phpstan-param array<int, int> $faces
* @return $this
*/
public function writeFacingFlags(array $faces) : self{
$result = 0;
foreach($faces as $face){
$result |= match($face){
Facing::DOWN => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_DOWN,
Facing::UP => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_UP,
Facing::NORTH => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_NORTH,
Facing::SOUTH => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_SOUTH,
Facing::WEST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_WEST,
Facing::EAST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_EAST,
default => throw new AssumptionFailedError("Unhandled face $face")
};
}
return $this->writeInt(BlockStateNames::MULTI_FACE_DIRECTION_BITS, $result);
}
/** @return $this */
public function writeEndRodFacingDirection(int $value) : self{
//end rods are stupid in bedrock and have everything except up/down the wrong way round