22declare(strict_types=1);
24namespace pocketmine\data\bedrock\block\convert;
26use pocketmine\block\utils\BellAttachmentType;
27use pocketmine\block\utils\SlabType;
28use pocketmine\block\utils\WallConnectionType;
48 private array $states = [];
50 public function __construct(
54 public static function create(
string $id) :
self{
59 public function writeBool(
string $name,
bool $value) : self{
60 $this->states[$name] = new
ByteTag($value ? 1 : 0);
65 public function writeInt(
string $name,
int $value) : self{
66 $this->states[$name] = new
IntTag($value);
71 public function writeString(
string $name,
string $value) : self{
72 $this->states[$name] = new
StringTag($value);
93 Facing::DOWN => StringValues::MC_BLOCK_FACE_DOWN,
94 Facing::UP => StringValues::MC_BLOCK_FACE_UP,
95 Facing::NORTH => StringValues::MC_BLOCK_FACE_NORTH,
96 Facing::SOUTH => StringValues::MC_BLOCK_FACE_SOUTH,
97 Facing::WEST => StringValues::MC_BLOCK_FACE_WEST,
98 Facing::EAST => StringValues::MC_BLOCK_FACE_EAST,
111 foreach($faces as $face){
112 $result |= match($face){
113 Facing::DOWN => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_DOWN,
114 Facing::UP => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_UP,
115 Facing::NORTH => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_NORTH,
116 Facing::SOUTH => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_SOUTH,
117 Facing::WEST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_WEST,
118 Facing::EAST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_EAST,
123 return $this->writeInt(BlockStateNames::MULTI_FACE_DIRECTION_BITS, $result);
129 return $this->writeFacingDirection(
Facing::axis($value) !==
Axis::Y ?
Facing::opposite($value) : $value);
138 return $this->writeFacingDirection($value);
184 return $this->writeString(
BlockStateNames::MC_CARDINAL_DIRECTION, match($value){
185 Facing::SOUTH => StringValues::MC_CARDINAL_DIRECTION_SOUTH,
186 Facing::WEST => StringValues::MC_CARDINAL_DIRECTION_WEST,
187 Facing::NORTH => StringValues::MC_CARDINAL_DIRECTION_NORTH,
188 Facing::EAST => StringValues::MC_CARDINAL_DIRECTION_EAST,
207 if($value ===
Facing::DOWN){
210 $this->writeFacingDirection($value);
216 if($value ===
Facing::UP){
219 $this->writeFacingDirection($value);
226 Axis::X => StringValues::PILLAR_AXIS_X,
227 Axis::Y => StringValues::PILLAR_AXIS_Y,
228 Axis::Z => StringValues::PILLAR_AXIS_Z,
236 $this->writeString(
BlockStateNames::MC_VERTICAL_HALF, match($slabType){
237 SlabType::TOP => StringValues::MC_VERTICAL_HALF_TOP,
238 SlabType::BOTTOM => StringValues::MC_VERTICAL_HALF_BOTTOM,
247 $this->writeString(
BlockStateNames::TORCH_FACING_DIRECTION, match($facing){
248 Facing::UP => StringValues::TORCH_FACING_DIRECTION_TOP,
249 Facing::SOUTH => StringValues::TORCH_FACING_DIRECTION_NORTH,
250 Facing::NORTH => StringValues::TORCH_FACING_DIRECTION_SOUTH,
251 Facing::EAST => StringValues::TORCH_FACING_DIRECTION_WEST,
252 Facing::WEST => StringValues::TORCH_FACING_DIRECTION_EAST,
260 $this->writeString(
BlockStateNames::ATTACHMENT, match($attachmentType){
261 BellAttachmentType::FLOOR => StringValues::ATTACHMENT_STANDING,
262 BellAttachmentType::CEILING => StringValues::ATTACHMENT_HANGING,
263 BellAttachmentType::ONE_WALL => StringValues::ATTACHMENT_SIDE,
264 BellAttachmentType::TWO_WALLS => StringValues::ATTACHMENT_MULTIPLE,
271 $this->writeString($name, match($wallConnectionType){
272 null => StringValues::WALL_CONNECTION_TYPE_EAST_NONE,
273 WallConnectionType::SHORT => StringValues::WALL_CONNECTION_TYPE_EAST_SHORT,
274 WallConnectionType::TALL => StringValues::WALL_CONNECTION_TYPE_EAST_TALL,
writeCoralFacing(int $value)
writeLegacyHorizontalFacing(int $value)
writeFacingDirection(int $value)
writeSlabPosition(SlabType $slabType)
writeFacingFlags(array $faces)
writeEndRodFacingDirection(int $value)
writeCardinalHorizontalFacing(int $value)
writeWeirdoHorizontalFacing(int $value)
writeBellAttachmentType(BellAttachmentType $attachmentType)
write5MinusHorizontalFacing(int $value)
writeTorchFacing(int $facing)
writeWallConnectionType(string $name, ?WallConnectionType $wallConnectionType)
writeFacingWithoutDown(int $value)
writeFacingWithoutUp(int $value)
writeHorizontalFacing(int $value)
writeBlockFace(int $value)
writePillarAxis(int $axis)
writeString(string $name, string $value)
writeBool(string $name, bool $value)
writeInt(string $name, int $value)