mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 11:18:52 +00:00
deduplicate weighted pressure plate deserializer code
This commit is contained in:
parent
cdafb1b0c4
commit
a91e7f7202
@ -510,10 +510,7 @@ final class BlockStateDeserializer{
|
|||||||
//TODO: intentionally ignored "deprecated" blockstate (useless)
|
//TODO: intentionally ignored "deprecated" blockstate (useless)
|
||||||
return VanillaBlocks::HAY_BALE()->setAxis($in->readPillarAxis());
|
return VanillaBlocks::HAY_BALE()->setAxis($in->readPillarAxis());
|
||||||
});
|
});
|
||||||
$this->map(Ids::HEAVY_WEIGHTED_PRESSURE_PLATE, function(BlockStateReader $in) : Block{
|
$this->map(Ids::HEAVY_WEIGHTED_PRESSURE_PLATE, fn(BlockStateReader $in) => Helper::decodeWeightedPressurePlate(VanillaBlocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), $in));
|
||||||
return VanillaBlocks::WEIGHTED_PRESSURE_PLATE_HEAVY()
|
|
||||||
->setOutputSignalStrength($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15));
|
|
||||||
});
|
|
||||||
$this->map(Ids::HOPPER, function(BlockStateReader $in) : Block{
|
$this->map(Ids::HOPPER, function(BlockStateReader $in) : Block{
|
||||||
return VanillaBlocks::HOPPER()
|
return VanillaBlocks::HOPPER()
|
||||||
->setFacing($in->readFacingWithoutUp())
|
->setFacing($in->readFacingWithoutUp())
|
||||||
@ -589,10 +586,7 @@ final class BlockStateDeserializer{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
$this->map(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, fn(BlockStateReader $in) => Helper::decodeGlazedTerracotta(VanillaBlocks::LIGHT_BLUE_GLAZED_TERRACOTTA(), $in));
|
$this->map(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, fn(BlockStateReader $in) => Helper::decodeGlazedTerracotta(VanillaBlocks::LIGHT_BLUE_GLAZED_TERRACOTTA(), $in));
|
||||||
$this->map(Ids::LIGHT_WEIGHTED_PRESSURE_PLATE, function(BlockStateReader $in) : Block{
|
$this->map(Ids::LIGHT_WEIGHTED_PRESSURE_PLATE, fn(BlockStateReader $in) => Helper::decodeWeightedPressurePlate(VanillaBlocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), $in));
|
||||||
return VanillaBlocks::WEIGHTED_PRESSURE_PLATE_LIGHT()
|
|
||||||
->setOutputSignalStrength($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15));
|
|
||||||
});
|
|
||||||
$this->map(Ids::LIME_GLAZED_TERRACOTTA, fn(BlockStateReader $in) => Helper::decodeGlazedTerracotta(VanillaBlocks::LIME_GLAZED_TERRACOTTA(), $in));
|
$this->map(Ids::LIME_GLAZED_TERRACOTTA, fn(BlockStateReader $in) => Helper::decodeGlazedTerracotta(VanillaBlocks::LIME_GLAZED_TERRACOTTA(), $in));
|
||||||
$this->map(Ids::LIT_BLAST_FURNACE, function(BlockStateReader $in) : Block{
|
$this->map(Ids::LIT_BLAST_FURNACE, function(BlockStateReader $in) : Block{
|
||||||
return VanillaBlocks::BLAST_FURNACE()
|
return VanillaBlocks::BLAST_FURNACE()
|
||||||
|
@ -46,6 +46,7 @@ use pocketmine\block\VanillaBlocks;
|
|||||||
use pocketmine\block\Wall;
|
use pocketmine\block\Wall;
|
||||||
use pocketmine\block\WallCoralFan;
|
use pocketmine\block\WallCoralFan;
|
||||||
use pocketmine\block\WallSign;
|
use pocketmine\block\WallSign;
|
||||||
|
use pocketmine\block\WeightedPressurePlate;
|
||||||
use pocketmine\data\bedrock\blockstate\BlockStateStringValues as StringValues;
|
use pocketmine\data\bedrock\blockstate\BlockStateStringValues as StringValues;
|
||||||
use pocketmine\data\bedrock\MushroomBlockTypeIdMap;
|
use pocketmine\data\bedrock\MushroomBlockTypeIdMap;
|
||||||
use pocketmine\math\Axis;
|
use pocketmine\math\Axis;
|
||||||
@ -209,6 +210,11 @@ final class BlockStateDeserializerHelper{
|
|||||||
->setFacing($in->readHorizontalFacing());
|
->setFacing($in->readHorizontalFacing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function decodeWeightedPressurePlate(WeightedPressurePlate $block, BlockStateReader $in) : WeightedPressurePlate{
|
||||||
|
return $block
|
||||||
|
->setOutputSignalStrength($in->readBoundedInt(BlockStateNames::REDSTONE_SIGNAL, 0, 15));
|
||||||
|
}
|
||||||
|
|
||||||
/** @throws BlockStateDeserializeException */
|
/** @throws BlockStateDeserializeException */
|
||||||
public static function mapStoneSlab1Type(BlockStateReader $in) : Slab{
|
public static function mapStoneSlab1Type(BlockStateReader $in) : Slab{
|
||||||
//* stone_slab_type (StringTag) = brick, cobblestone, nether_brick, quartz, sandstone, smooth_stone, stone_brick, wood
|
//* stone_slab_type (StringTag) = brick, cobblestone, nether_brick, quartz, sandstone, smooth_stone, stone_brick, wood
|
||||||
|
Loading…
x
Reference in New Issue
Block a user