mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-30 23:11:06 +00:00
Tidy up in block properties aisle
This commit is contained in:
parent
48ba334218
commit
beaedc3627
@ -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\FlattenedCaveVinesVariant;
|
||||||
use pocketmine\data\bedrock\block\convert\property\IntFromRawStateMap;
|
use pocketmine\data\bedrock\block\convert\property\IntFromRawStateMap;
|
||||||
use pocketmine\data\bedrock\block\convert\property\IntProperty;
|
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\ValueFromIntProperty;
|
||||||
use pocketmine\data\bedrock\block\convert\property\ValueFromStringProperty;
|
use pocketmine\data\bedrock\block\convert\property\ValueFromStringProperty;
|
||||||
use pocketmine\data\bedrock\block\convert\property\ValueMappings;
|
use pocketmine\data\bedrock\block\convert\property\ValueMappings;
|
||||||
|
use pocketmine\data\bedrock\block\convert\property\ValueSetFromIntProperty;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use function array_map;
|
use function array_map;
|
||||||
use function min;
|
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::RESIN_CLUMP(), Ids::RESIN_CLUMP)->properties([$commonProperties->multiFacingFlags]));
|
||||||
|
|
||||||
$reg->mapModel(Model::create(Blocks::VINES(), Ids::VINE)->properties([
|
$reg->mapModel(Model::create(Blocks::VINES(), Ids::VINE)->properties([
|
||||||
new OptionSetFromIntProperty(
|
new ValueSetFromIntProperty(
|
||||||
StateNames::VINE_DIRECTION_BITS,
|
StateNames::VINE_DIRECTION_BITS,
|
||||||
IntFromRawStateMap::int([
|
IntFromRawStateMap::int([
|
||||||
Facing::NORTH => BlockLegacyMetadata::VINE_FLAG_NORTH,
|
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::CHAIN(), Ids::CHAIN)->properties([$commonProperties->pillarAxis]));
|
||||||
$reg->mapModel(Model::create(Blocks::CHISELED_BOOKSHELF(), Ids::CHISELED_BOOKSHELF)->properties([
|
$reg->mapModel(Model::create(Blocks::CHISELED_BOOKSHELF(), Ids::CHISELED_BOOKSHELF)->properties([
|
||||||
$commonProperties->horizontalFacingSWNE,
|
$commonProperties->horizontalFacingSWNE,
|
||||||
new OptionSetFromIntProperty(
|
new ValueSetFromIntProperty(
|
||||||
StateNames::BOOKS_STORED,
|
StateNames::BOOKS_STORED,
|
||||||
EnumFromRawStateMap::int(ChiseledBookshelfSlot::class, fn(ChiseledBookshelfSlot $case) => match($case){
|
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
|
//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
|
||||||
|
@ -80,8 +80,8 @@ final class CommonProperties{
|
|||||||
/** @phpstan-var ValueFromIntProperty<AnyFacing, int> */
|
/** @phpstan-var ValueFromIntProperty<AnyFacing, int> */
|
||||||
public readonly ValueFromIntProperty $anyFacingClassic;
|
public readonly ValueFromIntProperty $anyFacingClassic;
|
||||||
|
|
||||||
/** @phpstan-var OptionSetFromIntProperty<MultiAnyFacing, int> */
|
/** @phpstan-var ValueSetFromIntProperty<MultiAnyFacing, int> */
|
||||||
public readonly OptionSetFromIntProperty $multiFacingFlags;
|
public readonly ValueSetFromIntProperty $multiFacingFlags;
|
||||||
|
|
||||||
/** @phpstan-var IntProperty<SignLikeRotation> */
|
/** @phpstan-var IntProperty<SignLikeRotation> */
|
||||||
public readonly IntProperty $floorSignLikeRotation;
|
public readonly IntProperty $floorSignLikeRotation;
|
||||||
@ -242,7 +242,7 @@ final class CommonProperties{
|
|||||||
fn(AnyFacing $b, int $v) => $b->setFacing($v)
|
fn(AnyFacing $b, int $v) => $b->setFacing($v)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->multiFacingFlags = new OptionSetFromIntProperty(
|
$this->multiFacingFlags = new ValueSetFromIntProperty(
|
||||||
StateNames::MULTI_FACE_DIRECTION_BITS,
|
StateNames::MULTI_FACE_DIRECTION_BITS,
|
||||||
IntFromRawStateMap::int([
|
IntFromRawStateMap::int([
|
||||||
Facing::DOWN => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_DOWN,
|
Facing::DOWN => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_DOWN,
|
||||||
|
@ -32,7 +32,7 @@ use pocketmine\utils\AssumptionFailedError;
|
|||||||
* @phpstan-template TOption of int|\UnitEnum
|
* @phpstan-template TOption of int|\UnitEnum
|
||||||
* @phpstan-implements Property<TBlock>
|
* @phpstan-implements Property<TBlock>
|
||||||
*/
|
*/
|
||||||
class OptionSetFromIntProperty implements Property{
|
class ValueSetFromIntProperty implements Property{
|
||||||
|
|
||||||
private int $maxValue = 0;
|
private int $maxValue = 0;
|
||||||
|
|
@ -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
|
* 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.
|
* 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
|
* TODO: get rid of this in PM6 and make the internal enum have a NONE case
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
enum WallConnectionTypeShim{
|
enum WallConnectionTypeShim{
|
||||||
case NONE;
|
case NONE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user