Implement Copper variant of existing blocks (#6839)

This commit is contained in:
Asfadavy Aulia A.
2025-10-13 21:39:50 +07:00
committed by GitHub
parent 32db9f9136
commit 06a75759bb
10 changed files with 142 additions and 10 deletions

View File

@@ -43,6 +43,7 @@ use pocketmine\block\ChiseledBookshelf;
use pocketmine\block\ChorusFlower;
use pocketmine\block\CocoaBlock;
use pocketmine\block\Copper;
use pocketmine\block\CopperLantern;
use pocketmine\block\DaylightSensor;
use pocketmine\block\DetectorRail;
use pocketmine\block\Dirt;
@@ -661,6 +662,25 @@ final class VanillaBlockMappings{
])
->properties([$commonProperties->slabPositionProperty])
);
$reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_BARS())->idComponents([...$commonProperties->copperIdPrefixes, "copper_bars"]));
$reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_CHAIN())
->idComponents([...$commonProperties->copperIdPrefixes, "copper_chain"])
->properties([$commonProperties->pillarAxis])
);
$reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_LANTERN())
->idComponents([...$commonProperties->copperIdPrefixes, "copper_lantern"])
->properties([
new BoolProperty(StateNames::HANGING, fn(CopperLantern $b) => $b->isHanging(), fn(CopperLantern $b, bool $v) => $b->setHanging($v))
])
);
$reg->mapFlattenedId(FlattenedIdModel::create(Blocks::LIGHTNING_ROD())
->idComponents([...$commonProperties->copperIdPrefixes, "lightning_rod"])
->properties([
$commonProperties->anyFacingClassic,
new DummyProperty(StateNames::POWERED_BIT, false) //TODO
])
);
}
private static function registerFlattenedEnumMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
@@ -1184,6 +1204,7 @@ final class VanillaBlockMappings{
private static function registerTorchMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
foreach([
[Blocks::BLUE_TORCH(), Ids::COLORED_TORCH_BLUE],
[Blocks::COPPER_TORCH(), Ids::COPPER_TORCH],
[Blocks::GREEN_TORCH(), Ids::COLORED_TORCH_GREEN],
[Blocks::PURPLE_TORCH(), Ids::COLORED_TORCH_PURPLE],
[Blocks::RED_TORCH(), Ids::COLORED_TORCH_RED],
@@ -1355,10 +1376,6 @@ final class VanillaBlockMappings{
new ValueFromStringProperty(StateNames::LEVER_DIRECTION, ValueMappings::getInstance()->leverFacing, fn(Lever $b) => $b->getFacing(), fn(Lever $b, LeverFacing $v) => $b->setFacing($v)),
new BoolProperty(StateNames::OPEN_BIT, fn(Lever $b) => $b->isActivated(), fn(Lever $b, bool $v) => $b->setActivated($v)),
]));
$reg->mapModel(Model::create(Blocks::LIGHTNING_ROD(), Ids::LIGHTNING_ROD)->properties([
$commonProperties->anyFacingClassic,
new DummyProperty(StateNames::POWERED_BIT, false) //TODO
]));
$reg->mapModel(Model::create(Blocks::LIT_PUMPKIN(), Ids::LIT_PUMPKIN)->properties([$commonProperties->horizontalFacingCardinal]));
$reg->mapModel(Model::create(Blocks::LOOM(), Ids::LOOM)->properties([$commonProperties->horizontalFacingSWNE]));