22declare(strict_types=1);
24namespace pocketmine\data\bedrock\block\convert;
51use pocketmine\block\utils\CopperOxidation;
52use pocketmine\block\utils\SlabType;
74 ->setFacing($in->readFacingDirection())
81 ->setCount($in->readBoundedInt(StateNames::CANDLES, 0, 3) + 1)
82 ->setLit($in->readBool(StateNames::LIT));
93 return $block->setAge($in->readBoundedInt(
BlockStateNames::GROWTH, 0, 7));
99 ->setFacing($in->readCardinalHorizontalFacing())
101 ->setSubtractMode($in->readBool(
BlockStateNames::OUTPUT_SUBTRACT_BIT));
111 $block->setOxidation($oxidation);
112 $block->setWaxed(
false);
123 $block->setOxidation($oxidation);
124 $block->setWaxed(
true);
131 ->setOutputSignalStrength($in->readBoundedInt(
BlockStateNames::REDSTONE_SIGNAL, 0, 15));
139 ->setFacing(
Facing::rotateY($in->readLegacyHorizontalFacing(), false))
153 ->setFacing($in->readLegacyHorizontalFacing())
161 ->setAxis(match($in->readBoundedInt(
BlockStateNames::CORAL_FAN_DIRECTION, 0, 1)){
171 ->setRotation($in->readBoundedInt(
BlockStateNames::GROUND_SIGN_DIRECTION, 0, 15));
175 $in->todo(StateNames::ITEM_FRAME_PHOTO_BIT);
184 ->setNoDecay($in->readBool(StateNames::PERSISTENT_BIT))
185 ->setCheckDecay($in->readBool(StateNames::UPDATE_BIT));
190 $fluidHeightState = $in->readBoundedInt(
BlockStateNames::LIQUID_DEPTH, 0, 15);
193 ->setFalling(($fluidHeightState & 0x8) !== 0)
198 return self::decodeLiquid($block, $in, false);
201 public static function decodeStillLiquid(Liquid $block, BlockStateReader $in) : Liquid{
202 return self::decodeLiquid($block, $in, true);
208 ->setAxis($in->readPillarAxis())
209 ->setStripped($stripped);
214 switch($type = $in->readBoundedInt(
BlockStateNames::HUGE_MUSHROOM_BITS, 0, 15)){
215 case BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM:
return VanillaBlocks::ALL_SIDED_MUSHROOM_STEM();
216 case BlockLegacyMetadata::MUSHROOM_BLOCK_STEM:
return VanillaBlocks::MUSHROOM_STEM();
219 $type = MushroomBlockTypeIdMap::getInstance()->fromId($type);
227 ->setFacing($in->readCardinalHorizontalFacing())
228 ->setDelay($in->readBoundedInt(
BlockStateNames::REPEATER_DELAY, 0, 3) + 1);
241 return $block->setPressed($in->readBoundedInt(
BlockStateNames::REDSTONE_SIGNAL, 0, 15) !== 0);
246 return $block->setSlabType($in->readSlabPosition());
251 $in->ignored(StateNames::MC_VERTICAL_HALF);
259 ->setFacing($in->readWeirdoHorizontalFacing());
267 $facing = $in->readFacingWithoutUp();
268 return self::decodeCrops($block, $in)
269 ->setFacing($facing === Facing::DOWN ? Facing::UP : $facing);
275 ->setFacing($in->read5MinusHorizontalFacing())
295 ->setFacing($in->readCoralFacing());
301 ->setFacing($in->readHorizontalFacing());
306 ->setOutputSignalStrength($in->readBoundedInt(
BlockStateNames::REDSTONE_SIGNAL, 0, 15));
311 return self::decodeWall(match($type = $in->readString(
BlockStateNames::WALL_BLOCK_TYPE)){
312 StringValues::WALL_BLOCK_TYPE_ANDESITE => VanillaBlocks::ANDESITE_WALL(),
313 StringValues::WALL_BLOCK_TYPE_BRICK => VanillaBlocks::BRICK_WALL(),
314 StringValues::WALL_BLOCK_TYPE_COBBLESTONE => VanillaBlocks::COBBLESTONE_WALL(),
315 StringValues::WALL_BLOCK_TYPE_DIORITE => VanillaBlocks::DIORITE_WALL(),
316 StringValues::WALL_BLOCK_TYPE_END_BRICK => VanillaBlocks::END_STONE_BRICK_WALL(),
317 StringValues::WALL_BLOCK_TYPE_GRANITE => VanillaBlocks::GRANITE_WALL(),
318 StringValues::WALL_BLOCK_TYPE_MOSSY_COBBLESTONE => VanillaBlocks::MOSSY_COBBLESTONE_WALL(),
319 StringValues::WALL_BLOCK_TYPE_MOSSY_STONE_BRICK => VanillaBlocks::MOSSY_STONE_BRICK_WALL(),
320 StringValues::WALL_BLOCK_TYPE_NETHER_BRICK => VanillaBlocks::NETHER_BRICK_WALL(),
321 StringValues::WALL_BLOCK_TYPE_PRISMARINE => VanillaBlocks::PRISMARINE_WALL(),
322 StringValues::WALL_BLOCK_TYPE_RED_NETHER_BRICK => VanillaBlocks::RED_NETHER_BRICK_WALL(),
323 StringValues::WALL_BLOCK_TYPE_RED_SANDSTONE => VanillaBlocks::RED_SANDSTONE_WALL(),
324 StringValues::WALL_BLOCK_TYPE_SANDSTONE => VanillaBlocks::SANDSTONE_WALL(),
325 StringValues::WALL_BLOCK_TYPE_STONE_BRICK => VanillaBlocks::STONE_BRICK_WALL(),
326 default =>
throw $in->badValueException(BlockStateNames::WALL_BLOCK_TYPE, $type),
setMushroomBlockType(MushroomBlockType $mushroomBlockType)
setSlabType(SlabType $slabType)
setConnection(int $face, ?WallConnectionType $type)
static decodeRepeater(RedstoneRepeater $block, BlockStateReader $in)
static decodeCrops(Crops $block, BlockStateReader $in)
static decodeMushroomBlock(RedMushroomBlock $block, BlockStateReader $in)
static decodeDoublePlant(DoublePlant $block, BlockStateReader $in)
static decodeDoubleSlab(Slab $block, BlockStateReader $in)
static decodeWallSign(WallSign $block, BlockStateReader $in)
static decodeLiquid(Liquid $block, BlockStateReader $in, bool $still)
static decodeLeaves(Leaves $block, BlockStateReader $in)
static decodeStairs(Stair $block, BlockStateReader $in)
static decodeWaxedCopper(Copper|CopperSlab|CopperStairs $block, CopperOxidation $oxidation)
static decodeCandle(Candle $block, BlockStateReader $in)
static decodeWall(Wall $block, BlockStateReader $in)
static decodeWallCoralFan(WallCoralFan $block, BlockStateReader $in)
static decodeTrapdoor(Trapdoor $block, BlockStateReader $in)
static decodeStem(Stem $block, BlockStateReader $in)
static decodeFenceGate(FenceGate $block, BlockStateReader $in)
static decodeFloorSign(FloorSign $block, BlockStateReader $in)
static decodeLog(Wood $block, bool $stripped, BlockStateReader $in)
static decodeSapling(Sapling $block, BlockStateReader $in)
static mapLegacyWallType(BlockStateReader $in)
static decodeDaylightSensor(DaylightSensor $block, BlockStateReader $in)
static decodeDoor(Door $block, BlockStateReader $in)
static decodeSingleSlab(Slab $block, BlockStateReader $in)
static decodeFloorCoralFan(FloorCoralFan $block, BlockStateReader $in)
static decodeSimplePressurePlate(SimplePressurePlate $block, BlockStateReader $in)
static decodeCopper(Copper|CopperSlab|CopperStairs $block, CopperOxidation $oxidation)
static decodeComparator(RedstoneComparator $block, BlockStateReader $in)
static decodeButton(Button $block, BlockStateReader $in)
readWallConnectionType(string $name)