Merge branch 'minor-next' into major-next

This commit is contained in:
Dylan K. Taylor
2025-08-29 20:56:59 +01:00
9 changed files with 21 additions and 15 deletions

View File

@ -24,8 +24,8 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\MultiAnyFacing;
use pocketmine\block\utils\MultiAnySupportTrait; use pocketmine\block\utils\MultiAnySupportTrait;
use pocketmine\block\utils\MultiFacing;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
use pocketmine\item\Fertilizer; use pocketmine\item\Fertilizer;
use pocketmine\item\Item; use pocketmine\item\Item;
@ -36,7 +36,7 @@ use pocketmine\world\World;
use function count; use function count;
use function shuffle; use function shuffle;
class GlowLichen extends Transparent implements MultiFacing{ class GlowLichen extends Transparent implements MultiAnyFacing{
use MultiAnySupportTrait; use MultiAnySupportTrait;
public function getLightLevel() : int{ public function getLightLevel() : int{

View File

@ -23,11 +23,11 @@ declare(strict_types=1);
namespace pocketmine\block; namespace pocketmine\block;
use pocketmine\block\utils\MultiAnyFacing;
use pocketmine\block\utils\MultiAnySupportTrait; use pocketmine\block\utils\MultiAnySupportTrait;
use pocketmine\block\utils\MultiFacing;
use pocketmine\block\utils\SupportType; use pocketmine\block\utils\SupportType;
final class ResinClump extends Transparent implements MultiFacing{ final class ResinClump extends Transparent implements MultiAnyFacing{
use MultiAnySupportTrait; use MultiAnySupportTrait;
public function isSolid() : bool{ public function isSolid() : bool{

View File

@ -27,7 +27,10 @@ interface Ageable{
public function getAge() : int; public function getAge() : int;
public function getMaxAge() : int;
/** /**
* Must be in range 0 - getMaxAge()
* @return $this * @return $this
*/ */
public function setAge(int $age) : self; public function setAge(int $age) : self;

View File

@ -38,6 +38,8 @@ trait AgeableTrait{
public function getAge() : int{ return $this->age; } public function getAge() : int{ return $this->age; }
public function getMaxAge() : int{ return self::MAX_AGE; }
/** /**
* @return $this * @return $this
*/ */

View File

@ -25,7 +25,7 @@ namespace pocketmine\block\utils;
use pocketmine\math\Facing; use pocketmine\math\Facing;
interface MultiFacing{ interface MultiAnyFacing{
/** /**
* @return int[] * @return int[]

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\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

View File

@ -46,7 +46,7 @@ use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\HorizontalFacing; use pocketmine\block\utils\HorizontalFacing;
use pocketmine\block\utils\Lightable; use pocketmine\block\utils\Lightable;
use pocketmine\block\utils\MultiFacing; use pocketmine\block\utils\MultiAnyFacing;
use pocketmine\block\utils\PillarRotation; use pocketmine\block\utils\PillarRotation;
use pocketmine\block\utils\SignLikeRotation; use pocketmine\block\utils\SignLikeRotation;
use pocketmine\block\utils\SlabType; use pocketmine\block\utils\SlabType;
@ -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<MultiFacing, 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,
@ -252,8 +252,8 @@ final class CommonProperties{
Facing::WEST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_WEST, Facing::WEST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_WEST,
Facing::EAST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_EAST Facing::EAST => BlockLegacyMetadata::MULTI_FACE_DIRECTION_FLAG_EAST
]), ]),
fn(MultiFacing $b) => $b->getFaces(), fn(MultiAnyFacing $b) => $b->getFaces(),
fn(MultiFacing $b, array $v) => $b->setFaces($v) fn(MultiAnyFacing $b, array $v) => $b->setFaces($v)
); );
$this->floorSignLikeRotation = new IntProperty(StateNames::GROUND_SIGN_DIRECTION, 0, 15, fn(SignLikeRotation $b) => $b->getRotation(), fn(SignLikeRotation $b, int $v) => $b->setRotation($v)); $this->floorSignLikeRotation = new IntProperty(StateNames::GROUND_SIGN_DIRECTION, 0, 15, fn(SignLikeRotation $b) => $b->getRotation(), fn(SignLikeRotation $b, int $v) => $b->setRotation($v));

View File

@ -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;

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 * 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;