Tidy up in block properties aisle

This commit is contained in:
Dylan K. Taylor 2025-08-29 13:07:09 +01:00
parent 48ba334218
commit beaedc3627
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 8 additions and 7 deletions

View File

@ -118,10 +118,10 @@ use pocketmine\data\bedrock\block\convert\property\EnumFromRawStateMap;
use pocketmine\data\bedrock\block\convert\property\FlattenedCaveVinesVariant;
use pocketmine\data\bedrock\block\convert\property\IntFromRawStateMap;
use pocketmine\data\bedrock\block\convert\property\IntProperty;
use pocketmine\data\bedrock\block\convert\property\OptionSetFromIntProperty;
use pocketmine\data\bedrock\block\convert\property\ValueFromIntProperty;
use pocketmine\data\bedrock\block\convert\property\ValueFromStringProperty;
use pocketmine\data\bedrock\block\convert\property\ValueMappings;
use pocketmine\data\bedrock\block\convert\property\ValueSetFromIntProperty;
use pocketmine\math\Facing;
use function array_map;
use function min;
@ -581,7 +581,7 @@ final class VanillaBlockMappings{
$reg->mapModel(Model::create(Blocks::RESIN_CLUMP(), Ids::RESIN_CLUMP)->properties([$commonProperties->multiFacingFlags]));
$reg->mapModel(Model::create(Blocks::VINES(), Ids::VINE)->properties([
new OptionSetFromIntProperty(
new ValueSetFromIntProperty(
StateNames::VINE_DIRECTION_BITS,
IntFromRawStateMap::int([
Facing::NORTH => BlockLegacyMetadata::VINE_FLAG_NORTH,
@ -1267,7 +1267,7 @@ final class VanillaBlockMappings{
$reg->mapModel(Model::create(Blocks::CHAIN(), Ids::CHAIN)->properties([$commonProperties->pillarAxis]));
$reg->mapModel(Model::create(Blocks::CHISELED_BOOKSHELF(), Ids::CHISELED_BOOKSHELF)->properties([
$commonProperties->horizontalFacingSWNE,
new OptionSetFromIntProperty(
new ValueSetFromIntProperty(
StateNames::BOOKS_STORED,
EnumFromRawStateMap::int(ChiseledBookshelfSlot::class, fn(ChiseledBookshelfSlot $case) => match($case){
//these are (currently) the same as the internal values, but it's best not to rely on those in case Mojang mess with the flags

View File

@ -80,8 +80,8 @@ final class CommonProperties{
/** @phpstan-var ValueFromIntProperty<AnyFacing, int> */
public readonly ValueFromIntProperty $anyFacingClassic;
/** @phpstan-var OptionSetFromIntProperty<MultiAnyFacing, int> */
public readonly OptionSetFromIntProperty $multiFacingFlags;
/** @phpstan-var ValueSetFromIntProperty<MultiAnyFacing, int> */
public readonly ValueSetFromIntProperty $multiFacingFlags;
/** @phpstan-var IntProperty<SignLikeRotation> */
public readonly IntProperty $floorSignLikeRotation;
@ -242,7 +242,7 @@ final class CommonProperties{
fn(AnyFacing $b, int $v) => $b->setFacing($v)
);
$this->multiFacingFlags = new OptionSetFromIntProperty(
$this->multiFacingFlags = new ValueSetFromIntProperty(
StateNames::MULTI_FACE_DIRECTION_BITS,
IntFromRawStateMap::int([
Facing::DOWN => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_DOWN,

View File

@ -32,7 +32,7 @@ use pocketmine\utils\AssumptionFailedError;
* @phpstan-template TOption of int|\UnitEnum
* @phpstan-implements Property<TBlock>
*/
class OptionSetFromIntProperty implements Property{
class ValueSetFromIntProperty implements Property{
private int $maxValue = 0;

View File

@ -30,6 +30,7 @@ use pocketmine\data\bedrock\block\BlockStateStringValues;
* Internally we use null for no connections, but accepting this in the mapping code would require a fair amount of
* extra complexity for this one case. This shim allows us to use the regular systems for handling walls.
* TODO: get rid of this in PM6 and make the internal enum have a NONE case
* @internal
*/
enum WallConnectionTypeShim{
case NONE;