mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
Start migrating EnumTrait enums to PHP 8.1 native enums
This commit is contained in:
parent
fe94379a93
commit
ae564e445d
@ -78,7 +78,7 @@ class Anvil extends Transparent implements Fallable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||||
|
@ -95,7 +95,7 @@ class Bamboo extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getOffsetSeed(int $x, int $y, int $z) : int{
|
private static function getOffsetSeed(int $x, int $y, int $z) : int{
|
||||||
|
@ -111,7 +111,7 @@ abstract class BaseBanner extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedBy(Block $block) : bool{
|
private function canBeSupportedBy(Block $block) : bool{
|
||||||
|
@ -131,6 +131,6 @@ abstract class BaseBigDripleaf extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
abstract class BaseCake extends Transparent implements FoodSource{
|
abstract class BaseCake extends Transparent implements FoodSource{
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\block\utils\BlockEventHelper;
|
use pocketmine\block\utils\BlockEventHelper;
|
||||||
use pocketmine\block\utils\CoralType;
|
|
||||||
use pocketmine\block\utils\CoralTypeTrait;
|
use pocketmine\block\utils\CoralTypeTrait;
|
||||||
use pocketmine\block\utils\SupportType;
|
use pocketmine\block\utils\SupportType;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
@ -33,11 +32,6 @@ use function mt_rand;
|
|||||||
abstract class BaseCoral extends Transparent{
|
abstract class BaseCoral extends Transparent{
|
||||||
use CoralTypeTrait;
|
use CoralTypeTrait;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->coralType = CoralType::TUBE();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
if(!$this->dead){
|
if(!$this->dead){
|
||||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200));
|
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200));
|
||||||
@ -78,6 +72,6 @@ abstract class BaseCoral extends Transparent{
|
|||||||
protected function recalculateCollisionBoxes() : array{ return []; }
|
protected function recalculateCollisionBoxes() : array{ return []; }
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ abstract class BaseSign extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function getSupportingFace() : int;
|
abstract protected function getSupportingFace() : int;
|
||||||
|
@ -87,7 +87,7 @@ class Bed extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHeadPart() : bool{
|
public function isHeadPart() : bool{
|
||||||
@ -209,7 +209,7 @@ class Bed extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE());
|
return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxStackSize() : int{ return 1; }
|
public function getMaxStackSize() : int{ return 1; }
|
||||||
|
@ -35,19 +35,13 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\RayTraceResult;
|
use pocketmine\math\RayTraceResult;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
use pocketmine\utils\AssumptionFailedError;
|
|
||||||
use pocketmine\world\BlockTransaction;
|
use pocketmine\world\BlockTransaction;
|
||||||
use pocketmine\world\sound\BellRingSound;
|
use pocketmine\world\sound\BellRingSound;
|
||||||
|
|
||||||
final class Bell extends Transparent{
|
final class Bell extends Transparent{
|
||||||
use HorizontalFacingTrait;
|
use HorizontalFacingTrait;
|
||||||
|
|
||||||
private BellAttachmentType $attachmentType;
|
private BellAttachmentType $attachmentType = BellAttachmentType::FLOOR;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->attachmentType = BellAttachmentType::FLOOR();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->bellAttachmentType($this->attachmentType);
|
$w->bellAttachmentType($this->attachmentType);
|
||||||
@ -55,12 +49,12 @@ final class Bell extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateCollisionBoxes() : array{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
if($this->attachmentType->equals(BellAttachmentType::FLOOR())){
|
if($this->attachmentType === BellAttachmentType::FLOOR){
|
||||||
return [
|
return [
|
||||||
AxisAlignedBB::one()->squash(Facing::axis($this->facing), 1 / 4)->trim(Facing::UP, 3 / 16)
|
AxisAlignedBB::one()->squash(Facing::axis($this->facing), 1 / 4)->trim(Facing::UP, 3 / 16)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if($this->attachmentType->equals(BellAttachmentType::CEILING())){
|
if($this->attachmentType === BellAttachmentType::CEILING){
|
||||||
return [
|
return [
|
||||||
AxisAlignedBB::one()->contract(1 / 4, 0, 1 / 4)->trim(Facing::DOWN, 1 / 4)
|
AxisAlignedBB::one()->contract(1 / 4, 0, 1 / 4)->trim(Facing::DOWN, 1 / 4)
|
||||||
];
|
];
|
||||||
@ -72,12 +66,12 @@ final class Bell extends Transparent{
|
|||||||
->trim(Facing::DOWN, 1 / 4);
|
->trim(Facing::DOWN, 1 / 4);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$this->attachmentType->equals(BellAttachmentType::ONE_WALL()) ? $box->trim($this->facing, 3 / 16) : $box
|
$this->attachmentType === BellAttachmentType::ONE_WALL ? $box->trim($this->facing, 3 / 16) : $box
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttachmentType() : BellAttachmentType{ return $this->attachmentType; }
|
public function getAttachmentType() : BellAttachmentType{ return $this->attachmentType; }
|
||||||
@ -89,7 +83,7 @@ final class Bell extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block, int $face) : bool{
|
private function canBeSupportedAt(Block $block, int $face) : bool{
|
||||||
return !$block->getAdjacentSupportType($face)->equals(SupportType::NONE());
|
return $block->getAdjacentSupportType($face) !== SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
@ -100,15 +94,15 @@ final class Bell extends Transparent{
|
|||||||
if($player !== null){
|
if($player !== null){
|
||||||
$this->setFacing(Facing::opposite($player->getHorizontalFacing()));
|
$this->setFacing(Facing::opposite($player->getHorizontalFacing()));
|
||||||
}
|
}
|
||||||
$this->setAttachmentType(BellAttachmentType::FLOOR());
|
$this->setAttachmentType(BellAttachmentType::FLOOR);
|
||||||
}elseif($face === Facing::DOWN){
|
}elseif($face === Facing::DOWN){
|
||||||
$this->setAttachmentType(BellAttachmentType::CEILING());
|
$this->setAttachmentType(BellAttachmentType::CEILING);
|
||||||
}else{
|
}else{
|
||||||
$this->setFacing($face);
|
$this->setFacing($face);
|
||||||
$this->setAttachmentType(
|
$this->setAttachmentType(
|
||||||
$this->canBeSupportedAt($blockReplace, $face) ?
|
$this->canBeSupportedAt($blockReplace, $face) ?
|
||||||
BellAttachmentType::TWO_WALLS() :
|
BellAttachmentType::TWO_WALLS :
|
||||||
BellAttachmentType::ONE_WALL()
|
BellAttachmentType::ONE_WALL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
@ -116,11 +110,10 @@ final class Bell extends Transparent{
|
|||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
foreach(match($this->attachmentType){
|
foreach(match($this->attachmentType){
|
||||||
BellAttachmentType::CEILING() => [Facing::UP],
|
BellAttachmentType::CEILING => [Facing::UP],
|
||||||
BellAttachmentType::FLOOR() => [Facing::DOWN],
|
BellAttachmentType::FLOOR => [Facing::DOWN],
|
||||||
BellAttachmentType::ONE_WALL() => [Facing::opposite($this->facing)],
|
BellAttachmentType::ONE_WALL => [Facing::opposite($this->facing)],
|
||||||
BellAttachmentType::TWO_WALLS() => [$this->facing, Facing::opposite($this->facing)],
|
BellAttachmentType::TWO_WALLS => [$this->facing, Facing::opposite($this->facing)]
|
||||||
default => throw new AssumptionFailedError("All cases of BellAttachmentType must be handled")
|
|
||||||
} as $supportBlockDirection){
|
} as $supportBlockDirection){
|
||||||
if(!$this->canBeSupportedAt($this, $supportBlockDirection)){
|
if(!$this->canBeSupportedAt($this, $supportBlockDirection)){
|
||||||
$this->position->getWorld()->useBreakOn($this->position);
|
$this->position->getWorld()->useBreakOn($this->position);
|
||||||
@ -159,10 +152,9 @@ final class Bell extends Transparent{
|
|||||||
|
|
||||||
private function isValidFaceToRing(int $faceHit) : bool{
|
private function isValidFaceToRing(int $faceHit) : bool{
|
||||||
return match($this->attachmentType){
|
return match($this->attachmentType){
|
||||||
BellAttachmentType::CEILING() => true,
|
BellAttachmentType::CEILING => true,
|
||||||
BellAttachmentType::FLOOR() => Facing::axis($faceHit) === Facing::axis($this->facing),
|
BellAttachmentType::FLOOR => Facing::axis($faceHit) === Facing::axis($this->facing),
|
||||||
BellAttachmentType::ONE_WALL(), BellAttachmentType::TWO_WALLS() => $faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true),
|
BellAttachmentType::ONE_WALL, BellAttachmentType::TWO_WALLS => $faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true),
|
||||||
default => throw new AssumptionFailedError("All cases of BellAttachmentType must be handled")
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,7 @@ use pocketmine\world\sound\DripleafTiltUpSound;
|
|||||||
|
|
||||||
class BigDripleafHead extends BaseBigDripleaf{
|
class BigDripleafHead extends BaseBigDripleaf{
|
||||||
|
|
||||||
protected DripleafState $leafState;
|
protected DripleafState $leafState = DripleafState::STABLE;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->leafState = DripleafState::STABLE();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
parent::describeBlockOnlyState($w);
|
parent::describeBlockOnlyState($w);
|
||||||
@ -76,20 +71,20 @@ class BigDripleafHead extends BaseBigDripleaf{
|
|||||||
|
|
||||||
private function getLeafTopOffset() : float{
|
private function getLeafTopOffset() : float{
|
||||||
return match($this->leafState){
|
return match($this->leafState){
|
||||||
DripleafState::STABLE(), DripleafState::UNSTABLE() => 1 / 16,
|
DripleafState::STABLE, DripleafState::UNSTABLE => 1 / 16,
|
||||||
DripleafState::PARTIAL_TILT() => 3 / 16,
|
DripleafState::PARTIAL_TILT => 3 / 16,
|
||||||
default => 0
|
default => 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityInside(Entity $entity) : bool{
|
public function onEntityInside(Entity $entity) : bool{
|
||||||
if(!$entity instanceof Projectile && $this->leafState->equals(DripleafState::STABLE())){
|
if(!$entity instanceof Projectile && $this->leafState === DripleafState::STABLE){
|
||||||
//the entity must be standing on top of the leaf - do not collapse if the entity is standing underneath
|
//the entity must be standing on top of the leaf - do not collapse if the entity is standing underneath
|
||||||
$intersection = AxisAlignedBB::one()
|
$intersection = AxisAlignedBB::one()
|
||||||
->offset($this->position->x, $this->position->y, $this->position->z)
|
->offset($this->position->x, $this->position->y, $this->position->z)
|
||||||
->trim(Facing::DOWN, 1 - $this->getLeafTopOffset());
|
->trim(Facing::DOWN, 1 - $this->getLeafTopOffset());
|
||||||
if($entity->getBoundingBox()->intersectsWith($intersection)){
|
if($entity->getBoundingBox()->intersectsWith($intersection)){
|
||||||
$this->setTiltAndScheduleTick(DripleafState::UNSTABLE());
|
$this->setTiltAndScheduleTick(DripleafState::UNSTABLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,22 +92,21 @@ class BigDripleafHead extends BaseBigDripleaf{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
|
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
|
||||||
if(!$this->leafState->equals(DripleafState::FULL_TILT())){
|
if($this->leafState !== DripleafState::FULL_TILT){
|
||||||
$this->setTiltAndScheduleTick(DripleafState::FULL_TILT());
|
$this->setTiltAndScheduleTick(DripleafState::FULL_TILT);
|
||||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onScheduledUpdate() : void{
|
public function onScheduledUpdate() : void{
|
||||||
if(!$this->leafState->equals(DripleafState::STABLE())){
|
if($this->leafState !== DripleafState::STABLE){
|
||||||
if($this->leafState->equals(DripleafState::FULL_TILT())){
|
if($this->leafState === DripleafState::FULL_TILT){
|
||||||
$this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE()));
|
$this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE));
|
||||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltUpSound());
|
$this->position->getWorld()->addSound($this->position, new DripleafTiltUpSound());
|
||||||
}else{
|
}else{
|
||||||
$this->setTiltAndScheduleTick(match($this->leafState->id()){
|
$this->setTiltAndScheduleTick(match($this->leafState){
|
||||||
DripleafState::UNSTABLE()->id() => DripleafState::PARTIAL_TILT(),
|
DripleafState::UNSTABLE => DripleafState::PARTIAL_TILT,
|
||||||
DripleafState::PARTIAL_TILT()->id() => DripleafState::FULL_TILT(),
|
DripleafState::PARTIAL_TILT => DripleafState::FULL_TILT,
|
||||||
default => throw new AssumptionFailedError("All types should be covered")
|
|
||||||
});
|
});
|
||||||
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
$this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound());
|
||||||
}
|
}
|
||||||
@ -120,7 +114,7 @@ class BigDripleafHead extends BaseBigDripleaf{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateCollisionBoxes() : array{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
if(!$this->leafState->equals(DripleafState::FULL_TILT())){
|
if($this->leafState !== DripleafState::FULL_TILT){
|
||||||
return [
|
return [
|
||||||
AxisAlignedBB::one()
|
AxisAlignedBB::one()
|
||||||
->trim(Facing::DOWN, 11 / 16)
|
->trim(Facing::DOWN, 11 / 16)
|
||||||
|
@ -877,7 +877,7 @@ class Block{
|
|||||||
* blocks placed on the given face can be supported by this block.
|
* blocks placed on the given face can be supported by this block.
|
||||||
*/
|
*/
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::FULL();
|
return SupportType::FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getAdjacentSupportType(int $facing) : SupportType{
|
protected function getAdjacentSupportType(int $facing) : SupportType{
|
||||||
|
@ -34,6 +34,7 @@ use pocketmine\math\Facing;
|
|||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
|
use function spl_object_id;
|
||||||
|
|
||||||
class BrewingStand extends Transparent{
|
class BrewingStand extends Transparent{
|
||||||
|
|
||||||
@ -61,18 +62,18 @@ class BrewingStand extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasSlot(BrewingStandSlot $slot) : bool{
|
public function hasSlot(BrewingStandSlot $slot) : bool{
|
||||||
return array_key_exists($slot->id(), $this->slots);
|
return array_key_exists(spl_object_id($slot), $this->slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSlot(BrewingStandSlot $slot, bool $occupied) : self{
|
public function setSlot(BrewingStandSlot $slot, bool $occupied) : self{
|
||||||
if($occupied){
|
if($occupied){
|
||||||
$this->slots[$slot->id()] = $slot;
|
$this->slots[spl_object_id($slot)] = $slot;
|
||||||
}else{
|
}else{
|
||||||
unset($this->slots[$slot->id()]);
|
unset($this->slots[spl_object_id($slot)]);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -89,7 +90,7 @@ class BrewingStand extends Transparent{
|
|||||||
public function setSlots(array $slots) : self{
|
public function setSlots(array $slots) : self{
|
||||||
$this->slots = [];
|
$this->slots = [];
|
||||||
foreach($slots as $slot){
|
foreach($slots as $slot){
|
||||||
$this->slots[$slot->id()] = $slot;
|
$this->slots[spl_object_id($slot)] = $slot;
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -114,7 +115,7 @@ class BrewingStand extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$changed = false;
|
$changed = false;
|
||||||
foreach(BrewingStandSlot::getAll() as $slot){
|
foreach(BrewingStandSlot::cases() as $slot){
|
||||||
$occupied = !$brewing->getInventory()->isSlotEmpty($slot->getSlotNumber());
|
$occupied = !$brewing->getInventory()->isSlotEmpty($slot->getSlotNumber());
|
||||||
if($occupied !== $this->hasSlot($slot)){
|
if($occupied !== $this->hasSlot($slot)){
|
||||||
$this->setSlot($slot, $occupied);
|
$this->setSlot($slot, $occupied);
|
||||||
|
@ -69,7 +69,7 @@ class Cactus extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onEntityInside(Entity $entity) : bool{
|
public function onEntityInside(Entity $entity) : bool{
|
||||||
|
@ -91,7 +91,7 @@ class Candle extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getCandleIfCompatibleType(Block $block) : ?Candle{
|
protected function getCandleIfCompatibleType(Block $block) : ?Candle{
|
||||||
|
@ -61,7 +61,7 @@ final class Cauldron extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return $facing === Facing::UP ? SupportType::EDGE() : SupportType::NONE();
|
return $facing === Facing::UP ? SupportType::EDGE : SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ class CaveVines extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return $block->getAdjacentSupportType(Facing::UP)->equals(SupportType::FULL()) || $block->hasSameTypeId($this);
|
return $block->getAdjacentSupportType(Facing::UP) === SupportType::FULL || $block->hasSameTypeId($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
@ -176,6 +176,6 @@ class CaveVines extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ final class Chain extends Transparent{
|
|||||||
use PillarRotationTrait;
|
use PillarRotationTrait;
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return $this->axis === Axis::Y && Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE();
|
return $this->axis === Axis::Y && Facing::axis($facing) === Axis::Y ? SupportType::CENTER : SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateCollisionBoxes() : array{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
|
@ -45,7 +45,7 @@ class Chest extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPostPlace() : void{
|
public function onPostPlace() : void{
|
||||||
|
@ -77,11 +77,11 @@ class CocoaBlock extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function canAttachTo(Block $block) : bool{
|
private function canAttachTo(Block $block) : bool{
|
||||||
return $block instanceof Wood && $block->getWoodType()->equals(WoodType::JUNGLE());
|
return $block instanceof Wood && $block->getWoodType() === WoodType::JUNGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
@ -23,14 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\block\utils\CopperOxidation;
|
|
||||||
use pocketmine\block\utils\CopperTrait;
|
use pocketmine\block\utils\CopperTrait;
|
||||||
|
|
||||||
class CopperStairs extends Stair{
|
class CopperStairs extends Stair{
|
||||||
use CopperTrait;
|
use CopperTrait;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->oxidation = CopperOxidation::NONE();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\block\utils\BlockEventHelper;
|
use pocketmine\block\utils\BlockEventHelper;
|
||||||
use pocketmine\block\utils\CoralType;
|
|
||||||
use pocketmine\block\utils\CoralTypeTrait;
|
use pocketmine\block\utils\CoralTypeTrait;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
@ -32,11 +31,6 @@ use function mt_rand;
|
|||||||
final class CoralBlock extends Opaque{
|
final class CoralBlock extends Opaque{
|
||||||
use CoralTypeTrait;
|
use CoralTypeTrait;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->coralType = CoralType::TUBE();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
if(!$this->dead){
|
if(!$this->dead){
|
||||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200));
|
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200));
|
||||||
|
@ -70,7 +70,7 @@ class DaylightSensor extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||||
|
@ -38,12 +38,7 @@ use pocketmine\world\sound\ItemUseOnBlockSound;
|
|||||||
use pocketmine\world\sound\WaterSplashSound;
|
use pocketmine\world\sound\WaterSplashSound;
|
||||||
|
|
||||||
class Dirt extends Opaque{
|
class Dirt extends Opaque{
|
||||||
protected DirtType $dirtType;
|
protected DirtType $dirtType = DirtType::NORMAL;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->dirtType = DirtType::NORMAL();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->dirtType($this->dirtType);
|
$w->dirtType($this->dirtType);
|
||||||
@ -62,16 +57,16 @@ class Dirt extends Opaque{
|
|||||||
if($face === Facing::UP && $item instanceof Hoe){
|
if($face === Facing::UP && $item instanceof Hoe){
|
||||||
$item->applyDamage(1);
|
$item->applyDamage(1);
|
||||||
|
|
||||||
$newBlock = $this->dirtType->equals(DirtType::NORMAL()) ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT();
|
$newBlock = $this->dirtType === DirtType::NORMAL ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT();
|
||||||
$center = $this->position->add(0.5, 0.5, 0.5);
|
$center = $this->position->add(0.5, 0.5, 0.5);
|
||||||
$world->addSound($center, new ItemUseOnBlockSound($newBlock));
|
$world->addSound($center, new ItemUseOnBlockSound($newBlock));
|
||||||
$world->setBlock($this->position, $newBlock);
|
$world->setBlock($this->position, $newBlock);
|
||||||
if($this->dirtType->equals(DirtType::ROOTED())){
|
if($this->dirtType === DirtType::ROOTED){
|
||||||
$world->dropItem($center, VanillaBlocks::HANGING_ROOTS()->asItem());
|
$world->dropItem($center, VanillaBlocks::HANGING_ROOTS()->asItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}elseif($this->dirtType->equals(DirtType::ROOTED()) && $item instanceof Fertilizer){
|
}elseif($this->dirtType === DirtType::ROOTED && $item instanceof Fertilizer){
|
||||||
$down = $this->getSide(Facing::DOWN);
|
$down = $this->getSide(Facing::DOWN);
|
||||||
if($down->getTypeId() !== BlockTypeIds::AIR){
|
if($down->getTypeId() !== BlockTypeIds::AIR){
|
||||||
return true;
|
return true;
|
||||||
|
@ -102,7 +102,7 @@ class Door extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -82,6 +82,6 @@ class DragonEgg extends Transparent implements Fallable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class EnchantingTable extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||||
|
@ -49,7 +49,7 @@ class EnderChest extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||||
|
@ -42,7 +42,7 @@ class Fence extends Transparent{
|
|||||||
|
|
||||||
foreach(Facing::HORIZONTAL as $facing){
|
foreach(Facing::HORIZONTAL as $facing){
|
||||||
$block = $this->getSide($facing);
|
$block = $this->getSide($facing);
|
||||||
if($block instanceof static || $block instanceof FenceGate || $block->getSupportType(Facing::opposite($facing))->equals(SupportType::FULL())){
|
if($block instanceof static || $block instanceof FenceGate || $block->getSupportType(Facing::opposite($facing)) === SupportType::FULL){
|
||||||
$this->connections[$facing] = true;
|
$this->connections[$facing] = true;
|
||||||
}else{
|
}else{
|
||||||
unset($this->connections[$facing]);
|
unset($this->connections[$facing]);
|
||||||
@ -98,6 +98,6 @@ class Fence extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE();
|
return Facing::axis($facing) === Axis::Y ? SupportType::CENTER : SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ class FenceGate extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkInWall() : bool{
|
private function checkInWall() : bool{
|
||||||
|
@ -64,7 +64,7 @@ abstract class FillableCauldron extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return $facing === Facing::UP ? SupportType::EDGE() : SupportType::NONE();
|
return $facing === Facing::UP ? SupportType::EDGE : SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function withFillLevel(int $fillLevel) : Block{
|
protected function withFillLevel(int $fillLevel) : Block{
|
||||||
|
@ -60,7 +60,7 @@ class Fire extends BaseFire{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedBy(Block $block) : bool{
|
private function canBeSupportedBy(Block $block) : bool{
|
||||||
return $block->getSupportType(Facing::UP)->equals(SupportType::FULL());
|
return $block->getSupportType(Facing::UP) === SupportType::FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -48,6 +48,6 @@ abstract class Flowable extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber;
|
|||||||
|
|
||||||
final class Froglight extends SimplePillar{
|
final class Froglight extends SimplePillar{
|
||||||
|
|
||||||
private FroglightType $froglightType;
|
private FroglightType $froglightType = FroglightType::OCHRE;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->froglightType = FroglightType::OCHRE();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->froglightType($this->froglightType);
|
$w->froglightType($this->froglightType);
|
||||||
|
@ -95,7 +95,7 @@ class GlowLichen extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced() : bool{
|
||||||
@ -121,7 +121,7 @@ class GlowLichen extends Transparent{
|
|||||||
$changed = false;
|
$changed = false;
|
||||||
|
|
||||||
foreach($this->faces as $face){
|
foreach($this->faces as $face){
|
||||||
if(!$this->getAdjacentSupportType($face)->equals(SupportType::FULL())){
|
if($this->getAdjacentSupportType($face) !== SupportType::FULL){
|
||||||
unset($this->faces[$face]);
|
unset($this->faces[$face]);
|
||||||
$changed = true;
|
$changed = true;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ class GlowLichen extends Transparent{
|
|||||||
$supportBlock = $world->getBlock($replacePos->getSide($spreadFace));
|
$supportBlock = $world->getBlock($replacePos->getSide($spreadFace));
|
||||||
$supportFace = Facing::opposite($spreadFace);
|
$supportFace = Facing::opposite($spreadFace);
|
||||||
|
|
||||||
if(!$supportBlock->getSupportType($supportFace)->equals(SupportType::FULL())){
|
if($supportBlock->getSupportType($supportFace) !== SupportType::FULL){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ class GlowLichen extends Transparent{
|
|||||||
private function getAvailableFaces() : array{
|
private function getAvailableFaces() : array{
|
||||||
$faces = [];
|
$faces = [];
|
||||||
foreach(Facing::ALL as $face){
|
foreach(Facing::ALL as $face){
|
||||||
if(!$this->hasFace($face) && $this->getAdjacentSupportType($face)->equals(SupportType::FULL())){
|
if(!$this->hasFace($face) && $this->getAdjacentSupportType($face) === SupportType::FULL){
|
||||||
$faces[$face] = $face;
|
$faces[$face] = $face;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class Grass extends Opaque{
|
|||||||
$b = $world->getBlockAt($x, $y, $z);
|
$b = $world->getBlockAt($x, $y, $z);
|
||||||
if(
|
if(
|
||||||
!($b instanceof Dirt) ||
|
!($b instanceof Dirt) ||
|
||||||
!$b->getDirtType()->equals(DirtType::NORMAL()) ||
|
$b->getDirtType() !== DirtType::NORMAL ||
|
||||||
$world->getFullLightAt($x, $y + 1, $z) < 4 ||
|
$world->getFullLightAt($x, $y + 1, $z) < 4 ||
|
||||||
$world->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
$world->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
||||||
){
|
){
|
||||||
|
@ -68,9 +68,9 @@ class Hopper extends Transparent{
|
|||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return match($facing){
|
return match($facing){
|
||||||
Facing::UP => SupportType::FULL(),
|
Facing::UP => SupportType::FULL,
|
||||||
Facing::DOWN => $this->facing === Facing::DOWN ? SupportType::CENTER() : SupportType::NONE(),
|
Facing::DOWN => $this->facing === Facing::DOWN ? SupportType::CENTER : SupportType::NONE,
|
||||||
default => SupportType::NONE()
|
default => SupportType::NONE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ class ItemFrame extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block, int $face) : bool{
|
private function canBeSupportedAt(Block $block, int $face) : bool{
|
||||||
return !$block->getAdjacentSupportType($face)->equals(SupportType::NONE());
|
return $block->getAdjacentSupportType($face) !== SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -66,7 +66,7 @@ class Ladder extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
@ -85,6 +85,6 @@ class Ladder extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block, int $face) : bool{
|
private function canBeSupportedAt(Block $block, int $face) : bool{
|
||||||
return $block->getAdjacentSupportType($face)->equals(SupportType::FULL());
|
return $block->getAdjacentSupportType($face) === SupportType::FULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ class Lantern extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
@ -147,23 +147,22 @@ class Leaves extends Transparent{
|
|||||||
if(FortuneDropHelper::bonusChanceDivisor($item, 20, 4)){ //Saplings
|
if(FortuneDropHelper::bonusChanceDivisor($item, 20, 4)){ //Saplings
|
||||||
// TODO: according to the wiki, the jungle saplings have a different drop rate
|
// TODO: according to the wiki, the jungle saplings have a different drop rate
|
||||||
$sapling = (match($this->leavesType){
|
$sapling = (match($this->leavesType){
|
||||||
LeavesType::ACACIA() => VanillaBlocks::ACACIA_SAPLING(),
|
LeavesType::ACACIA => VanillaBlocks::ACACIA_SAPLING(),
|
||||||
LeavesType::BIRCH() => VanillaBlocks::BIRCH_SAPLING(),
|
LeavesType::BIRCH => VanillaBlocks::BIRCH_SAPLING(),
|
||||||
LeavesType::DARK_OAK() => VanillaBlocks::DARK_OAK_SAPLING(),
|
LeavesType::DARK_OAK => VanillaBlocks::DARK_OAK_SAPLING(),
|
||||||
LeavesType::JUNGLE() => VanillaBlocks::JUNGLE_SAPLING(),
|
LeavesType::JUNGLE => VanillaBlocks::JUNGLE_SAPLING(),
|
||||||
LeavesType::OAK() => VanillaBlocks::OAK_SAPLING(),
|
LeavesType::OAK => VanillaBlocks::OAK_SAPLING(),
|
||||||
LeavesType::SPRUCE() => VanillaBlocks::SPRUCE_SAPLING(),
|
LeavesType::SPRUCE => VanillaBlocks::SPRUCE_SAPLING(),
|
||||||
LeavesType::MANGROVE(), //TODO: mangrove propagule
|
LeavesType::MANGROVE, //TODO: mangrove propagule
|
||||||
LeavesType::AZALEA(), LeavesType::FLOWERING_AZALEA() => null, //TODO: azalea
|
LeavesType::AZALEA, LeavesType::FLOWERING_AZALEA => null, //TODO: azalea
|
||||||
LeavesType::CHERRY() => null, //TODO: cherry
|
LeavesType::CHERRY => null, //TODO: cherry
|
||||||
default => throw new AssumptionFailedError("Unreachable")
|
|
||||||
})?->asItem();
|
})?->asItem();
|
||||||
if($sapling !== null){
|
if($sapling !== null){
|
||||||
$drops[] = $sapling;
|
$drops[] = $sapling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
($this->leavesType->equals(LeavesType::OAK()) || $this->leavesType->equals(LeavesType::DARK_OAK())) &&
|
($this->leavesType === LeavesType::OAK || $this->leavesType === LeavesType::DARK_OAK) &&
|
||||||
FortuneDropHelper::bonusChanceDivisor($item, 200, 20)
|
FortuneDropHelper::bonusChanceDivisor($item, 200, 20)
|
||||||
){ //Apples
|
){ //Apples
|
||||||
$drops[] = VanillaItems::APPLE();
|
$drops[] = VanillaItems::APPLE();
|
||||||
@ -188,6 +187,6 @@ class Leaves extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ class Lectern extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isProducingSignal() : bool{ return $this->producingSignal; }
|
public function isProducingSignal() : bool{ return $this->producingSignal; }
|
||||||
|
@ -36,14 +36,9 @@ use pocketmine\world\sound\RedstonePowerOffSound;
|
|||||||
use pocketmine\world\sound\RedstonePowerOnSound;
|
use pocketmine\world\sound\RedstonePowerOnSound;
|
||||||
|
|
||||||
class Lever extends Flowable{
|
class Lever extends Flowable{
|
||||||
protected LeverFacing $facing;
|
protected LeverFacing $facing = LeverFacing::UP_AXIS_X;
|
||||||
protected bool $activated = false;
|
protected bool $activated = false;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->facing = LeverFacing::UP_AXIS_X();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->leverFacing($this->facing);
|
$w->leverFacing($this->facing);
|
||||||
$w->bool($this->activated);
|
$w->bool($this->activated);
|
||||||
@ -77,12 +72,12 @@ class Lever extends Flowable{
|
|||||||
return $x;
|
return $x;
|
||||||
};
|
};
|
||||||
$this->facing = match($face){
|
$this->facing = match($face){
|
||||||
Facing::DOWN => $selectUpDownPos(LeverFacing::DOWN_AXIS_X(), LeverFacing::DOWN_AXIS_Z()),
|
Facing::DOWN => $selectUpDownPos(LeverFacing::DOWN_AXIS_X, LeverFacing::DOWN_AXIS_Z),
|
||||||
Facing::UP => $selectUpDownPos(LeverFacing::UP_AXIS_X(), LeverFacing::UP_AXIS_Z()),
|
Facing::UP => $selectUpDownPos(LeverFacing::UP_AXIS_X, LeverFacing::UP_AXIS_Z),
|
||||||
Facing::NORTH => LeverFacing::NORTH(),
|
Facing::NORTH => LeverFacing::NORTH,
|
||||||
Facing::SOUTH => LeverFacing::SOUTH(),
|
Facing::SOUTH => LeverFacing::SOUTH,
|
||||||
Facing::WEST => LeverFacing::WEST(),
|
Facing::WEST => LeverFacing::WEST,
|
||||||
Facing::EAST => LeverFacing::EAST(),
|
Facing::EAST => LeverFacing::EAST,
|
||||||
default => throw new AssumptionFailedError("Bad facing value"),
|
default => throw new AssumptionFailedError("Bad facing value"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ abstract class Liquid extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDropsForCompatibleTool(Item $item) : array{
|
public function getDropsForCompatibleTool(Item $item) : array{
|
||||||
|
@ -39,16 +39,11 @@ class MobHead extends Flowable{
|
|||||||
public const MIN_ROTATION = 0;
|
public const MIN_ROTATION = 0;
|
||||||
public const MAX_ROTATION = 15;
|
public const MAX_ROTATION = 15;
|
||||||
|
|
||||||
protected MobHeadType $mobHeadType;
|
protected MobHeadType $mobHeadType = MobHeadType::SKELETON;
|
||||||
|
|
||||||
protected int $facing = Facing::NORTH;
|
protected int $facing = Facing::NORTH;
|
||||||
protected int $rotation = self::MIN_ROTATION; //TODO: split this into floor skull and wall skull handling
|
protected int $rotation = self::MIN_ROTATION; //TODO: split this into floor skull and wall skull handling
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->mobHeadType = MobHeadType::SKELETON(); //TODO: this should be a parameter
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->mobHeadType($this->mobHeadType);
|
$w->mobHeadType($this->mobHeadType);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,6 @@ class MonsterSpawner extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ class Mycelium extends Opaque{
|
|||||||
$z = mt_rand($this->position->z - 1, $this->position->z + 1);
|
$z = mt_rand($this->position->z - 1, $this->position->z + 1);
|
||||||
$world = $this->position->getWorld();
|
$world = $this->position->getWorld();
|
||||||
$block = $world->getBlockAt($x, $y, $z);
|
$block = $world->getBlockAt($x, $y, $z);
|
||||||
if($block instanceof Dirt && $block->getDirtType()->equals(DirtType::NORMAL())){
|
if($block instanceof Dirt && $block->getDirtType() === DirtType::NORMAL){
|
||||||
if($block->getSide(Facing::UP) instanceof Transparent){
|
if($block->getSide(Facing::UP) instanceof Transparent){
|
||||||
BlockEventHelper::spread($block, VanillaBlocks::MYCELIUM(), $this);
|
BlockEventHelper::spread($block, VanillaBlocks::MYCELIUM(), $this);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class NetherPortal extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item) : array{
|
public function getDrops(Item $item) : array{
|
||||||
|
@ -184,6 +184,6 @@ class NetherVines extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ abstract class PressurePlate extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
@ -71,7 +71,7 @@ abstract class PressurePlate extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE());
|
return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
|
@ -29,12 +29,7 @@ use pocketmine\item\Item;
|
|||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
|
|
||||||
class RedMushroomBlock extends Opaque{
|
class RedMushroomBlock extends Opaque{
|
||||||
protected MushroomBlockType $mushroomBlockType;
|
protected MushroomBlockType $mushroomBlockType = MushroomBlockType::ALL_CAP;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->mushroomBlockType = MushroomBlockType::ALL_CAP();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
//these blocks always drop as all-cap, but may exist in other forms in the inventory (particularly creative),
|
//these blocks always drop as all-cap, but may exist in other forms in the inventory (particularly creative),
|
||||||
@ -61,10 +56,10 @@ class RedMushroomBlock extends Opaque{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSilkTouchDrops(Item $item) : array{
|
public function getSilkTouchDrops(Item $item) : array{
|
||||||
return [(clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP())->asItem()];
|
return [(clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP)->asItem()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPickedItem(bool $addUserData = false) : Item{
|
public function getPickedItem(bool $addUserData = false) : Item{
|
||||||
return (clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP())->asItem();
|
return (clone $this)->setMushroomBlockType(MushroomBlockType::ALL_CAP)->asItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class RedstoneComparator extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE());
|
return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: redstone functionality
|
//TODO: redstone functionality
|
||||||
|
@ -94,7 +94,7 @@ class RedstoneRepeater extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return !$block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::NONE());
|
return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: redstone functionality
|
//TODO: redstone functionality
|
||||||
|
@ -78,7 +78,7 @@ class SeaPickle extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{
|
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{
|
||||||
|
@ -113,6 +113,6 @@ class ShulkerBox extends Opaque{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,9 @@ use pocketmine\player\Player;
|
|||||||
use pocketmine\world\BlockTransaction;
|
use pocketmine\world\BlockTransaction;
|
||||||
|
|
||||||
class Slab extends Transparent{
|
class Slab extends Transparent{
|
||||||
protected SlabType $slabType;
|
protected SlabType $slabType = SlabType::BOTTOM;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
||||||
$this->slabType = SlabType::BOTTOM();
|
|
||||||
parent::__construct($idInfo, $name . " Slab", $typeInfo);
|
parent::__construct($idInfo, $name . " Slab", $typeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ class Slab extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function isTransparent() : bool{
|
public function isTransparent() : bool{
|
||||||
return !$this->slabType->equals(SlabType::DOUBLE());
|
return $this->slabType !== SlabType::DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,8 +68,8 @@ class Slab extends Transparent{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->hasSameTypeId($this)){
|
if($blockReplace instanceof Slab && $blockReplace->slabType !== SlabType::DOUBLE && $blockReplace->hasSameTypeId($this)){
|
||||||
if($blockReplace->slabType->equals(SlabType::TOP())){ //Trying to combine with top slab
|
if($blockReplace->slabType === SlabType::TOP){ //Trying to combine with top slab
|
||||||
return $clickVector->y <= 0.5 || (!$isClickedBlock && $face === Facing::UP);
|
return $clickVector->y <= 0.5 || (!$isClickedBlock && $face === Facing::UP);
|
||||||
}else{
|
}else{
|
||||||
return $clickVector->y >= 0.5 || (!$isClickedBlock && $face === Facing::DOWN);
|
return $clickVector->y >= 0.5 || (!$isClickedBlock && $face === Facing::DOWN);
|
||||||
@ -81,14 +80,14 @@ class Slab extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->hasSameTypeId($this) && (
|
if($blockReplace instanceof Slab && $blockReplace->slabType !== SlabType::DOUBLE && $blockReplace->hasSameTypeId($this) && (
|
||||||
($blockReplace->slabType->equals(SlabType::TOP()) && ($clickVector->y <= 0.5 || $face === Facing::UP)) ||
|
($blockReplace->slabType === SlabType::TOP && ($clickVector->y <= 0.5 || $face === Facing::UP)) ||
|
||||||
($blockReplace->slabType->equals(SlabType::BOTTOM()) && ($clickVector->y >= 0.5 || $face === Facing::DOWN))
|
($blockReplace->slabType === SlabType::BOTTOM && ($clickVector->y >= 0.5 || $face === Facing::DOWN))
|
||||||
)){
|
)){
|
||||||
//Clicked in empty half of existing slab
|
//Clicked in empty half of existing slab
|
||||||
$this->slabType = SlabType::DOUBLE();
|
$this->slabType = SlabType::DOUBLE;
|
||||||
}else{
|
}else{
|
||||||
$this->slabType = (($face !== Facing::UP && $clickVector->y > 0.5) || $face === Facing::DOWN) ? SlabType::TOP() : SlabType::BOTTOM();
|
$this->slabType = (($face !== Facing::UP && $clickVector->y > 0.5) || $face === Facing::DOWN) ? SlabType::TOP : SlabType::BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
@ -98,22 +97,22 @@ class Slab extends Transparent{
|
|||||||
* @return AxisAlignedBB[]
|
* @return AxisAlignedBB[]
|
||||||
*/
|
*/
|
||||||
protected function recalculateCollisionBoxes() : array{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
if($this->slabType->equals(SlabType::DOUBLE())){
|
if($this->slabType === SlabType::DOUBLE){
|
||||||
return [AxisAlignedBB::one()];
|
return [AxisAlignedBB::one()];
|
||||||
}
|
}
|
||||||
return [AxisAlignedBB::one()->trim($this->slabType->equals(SlabType::TOP()) ? Facing::DOWN : Facing::UP, 0.5)];
|
return [AxisAlignedBB::one()->trim($this->slabType === SlabType::TOP ? Facing::DOWN : Facing::UP, 0.5)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
if($this->slabType->equals(SlabType::DOUBLE())){
|
if($this->slabType === SlabType::DOUBLE){
|
||||||
return SupportType::FULL();
|
return SupportType::FULL;
|
||||||
}elseif(($facing === Facing::UP && $this->slabType->equals(SlabType::TOP())) || ($facing === Facing::DOWN && $this->slabType->equals(SlabType::BOTTOM()))){
|
}elseif(($facing === Facing::UP && $this->slabType === SlabType::TOP) || ($facing === Facing::DOWN && $this->slabType === SlabType::BOTTOM)){
|
||||||
return SupportType::FULL();
|
return SupportType::FULL;
|
||||||
}
|
}
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDropsForCompatibleTool(Item $item) : array{
|
public function getDropsForCompatibleTool(Item $item) : array{
|
||||||
return [$this->asItem()->setCount($this->slabType->equals(SlabType::DOUBLE()) ? 2 : 1)];
|
return [$this->asItem()->setCount($this->slabType === SlabType::DOUBLE ? 2 : 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ class SmallDripleaf extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function recalculateCollisionBoxes() : array{
|
protected function recalculateCollisionBoxes() : array{
|
||||||
|
@ -75,13 +75,13 @@ class SnowLayer extends Flowable implements Fallable{
|
|||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
if(!$this->canBeReplaced()){
|
if(!$this->canBeReplaced()){
|
||||||
return SupportType::FULL();
|
return SupportType::FULL;
|
||||||
}
|
}
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return $block->getAdjacentSupportType(Facing::DOWN)->equals(SupportType::FULL());
|
return $block->getAdjacentSupportType(Facing::DOWN) === SupportType::FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
@ -33,7 +33,7 @@ use pocketmine\world\BlockTransaction;
|
|||||||
final class SporeBlossom extends Flowable{
|
final class SporeBlossom extends Flowable{
|
||||||
|
|
||||||
private function canBeSupportedAt(Block $block) : bool{
|
private function canBeSupportedAt(Block $block) : bool{
|
||||||
return $block->getAdjacentSupportType(Facing::UP)->equals(SupportType::FULL());
|
return $block->getAdjacentSupportType(Facing::UP) === SupportType::FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
@ -39,12 +39,7 @@ class Stair extends Transparent{
|
|||||||
use HorizontalFacingTrait;
|
use HorizontalFacingTrait;
|
||||||
|
|
||||||
protected bool $upsideDown = false;
|
protected bool $upsideDown = false;
|
||||||
protected StairShape $shape;
|
protected StairShape $shape = StairShape::STRAIGHT;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->shape = StairShape::STRAIGHT();
|
|
||||||
parent::__construct($idInfo, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||||
$w->horizontalFacing($this->facing);
|
$w->horizontalFacing($this->facing);
|
||||||
@ -56,11 +51,11 @@ class Stair extends Transparent{
|
|||||||
|
|
||||||
$clockwise = Facing::rotateY($this->facing, true);
|
$clockwise = Facing::rotateY($this->facing, true);
|
||||||
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
|
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
|
||||||
$this->shape = $backFacing === $clockwise ? StairShape::OUTER_RIGHT() : StairShape::OUTER_LEFT();
|
$this->shape = $backFacing === $clockwise ? StairShape::OUTER_RIGHT : StairShape::OUTER_LEFT;
|
||||||
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
|
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
|
||||||
$this->shape = $frontFacing === $clockwise ? StairShape::INNER_RIGHT() : StairShape::INNER_LEFT();
|
$this->shape = $frontFacing === $clockwise ? StairShape::INNER_RIGHT : StairShape::INNER_LEFT;
|
||||||
}else{
|
}else{
|
||||||
$this->shape = StairShape::STRAIGHT();
|
$this->shape = StairShape::STRAIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -92,14 +87,14 @@ class Stair extends Transparent{
|
|||||||
->trim(Facing::opposite($topStepFace), 0.5)
|
->trim(Facing::opposite($topStepFace), 0.5)
|
||||||
->trim(Facing::opposite($this->facing), 0.5);
|
->trim(Facing::opposite($this->facing), 0.5);
|
||||||
|
|
||||||
if($this->shape->equals(StairShape::OUTER_LEFT()) || $this->shape->equals(StairShape::OUTER_RIGHT())){
|
if($this->shape === StairShape::OUTER_LEFT || $this->shape === StairShape::OUTER_RIGHT){
|
||||||
$topStep->trim(Facing::rotateY($this->facing, $this->shape->equals(StairShape::OUTER_LEFT())), 0.5);
|
$topStep->trim(Facing::rotateY($this->facing, $this->shape === StairShape::OUTER_LEFT), 0.5);
|
||||||
}elseif($this->shape->equals(StairShape::INNER_LEFT()) || $this->shape->equals(StairShape::INNER_RIGHT())){
|
}elseif($this->shape === StairShape::INNER_LEFT || $this->shape === StairShape::INNER_RIGHT){
|
||||||
//add an extra cube
|
//add an extra cube
|
||||||
$bbs[] = AxisAlignedBB::one()
|
$bbs[] = AxisAlignedBB::one()
|
||||||
->trim(Facing::opposite($topStepFace), 0.5)
|
->trim(Facing::opposite($topStepFace), 0.5)
|
||||||
->trim($this->facing, 0.5) //avoid overlapping with main step
|
->trim($this->facing, 0.5) //avoid overlapping with main step
|
||||||
->trim(Facing::rotateY($this->facing, $this->shape->equals(StairShape::INNER_LEFT())), 0.5);
|
->trim(Facing::rotateY($this->facing, $this->shape === StairShape::INNER_LEFT), 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
$bbs[] = $topStep;
|
$bbs[] = $topStep;
|
||||||
@ -111,13 +106,13 @@ class Stair extends Transparent{
|
|||||||
if(
|
if(
|
||||||
$facing === Facing::UP && $this->isUpsideDown() ||
|
$facing === Facing::UP && $this->isUpsideDown() ||
|
||||||
$facing === Facing::DOWN && !$this->isUpsideDown() ||
|
$facing === Facing::DOWN && !$this->isUpsideDown() ||
|
||||||
($facing === $this->facing && !$this->shape->equals(StairShape::OUTER_LEFT()) && !$this->shape->equals(StairShape::OUTER_RIGHT())) ||
|
($facing === $this->facing && $this->shape !== StairShape::OUTER_LEFT && $this->shape !== StairShape::OUTER_RIGHT) ||
|
||||||
($facing === Facing::rotate($this->facing, Axis::Y, false) && $this->shape->equals(StairShape::INNER_LEFT())) ||
|
($facing === Facing::rotate($this->facing, Axis::Y, false) && $this->shape === StairShape::INNER_LEFT) ||
|
||||||
($facing === Facing::rotate($this->facing, Axis::Y, true) && $this->shape->equals(StairShape::INNER_RIGHT()))
|
($facing === Facing::rotate($this->facing, Axis::Y, true) && $this->shape === StairShape::INNER_RIGHT)
|
||||||
){
|
){
|
||||||
return SupportType::FULL();
|
return SupportType::FULL;
|
||||||
}
|
}
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPossibleCornerFacing(bool $oppositeFacing) : ?int{
|
private function getPossibleCornerFacing(bool $oppositeFacing) : ?int{
|
||||||
|
@ -47,6 +47,6 @@ class Stonecutter extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class Thin extends Transparent{
|
|||||||
|
|
||||||
foreach(Facing::HORIZONTAL as $facing){
|
foreach(Facing::HORIZONTAL as $facing){
|
||||||
$side = $this->getSide($facing);
|
$side = $this->getSide($facing);
|
||||||
if($side instanceof Thin || $side instanceof Wall || $side->getSupportType(Facing::opposite($facing))->equals(SupportType::FULL())){
|
if($side instanceof Thin || $side instanceof Wall || $side->getSupportType(Facing::opposite($facing)) === SupportType::FULL){
|
||||||
$this->connections[$facing] = true;
|
$this->connections[$facing] = true;
|
||||||
}else{
|
}else{
|
||||||
unset($this->connections[$facing]);
|
unset($this->connections[$facing]);
|
||||||
@ -90,6 +90,6 @@ class Thin extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,6 @@ class Torch extends Flowable{
|
|||||||
private function canBeSupportedAt(Block $block, int $face) : bool{
|
private function canBeSupportedAt(Block $block, int $face) : bool{
|
||||||
return $face === Facing::DOWN ?
|
return $face === Facing::DOWN ?
|
||||||
$block->getAdjacentSupportType($face)->hasCenterSupport() :
|
$block->getAdjacentSupportType($face)->hasCenterSupport() :
|
||||||
$block->getAdjacentSupportType($face)->equals(SupportType::FULL());
|
$block->getAdjacentSupportType($face) === SupportType::FULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class Trapdoor extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return SupportType::NONE();
|
return SupportType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
|
@ -68,6 +68,7 @@ use pocketmine\utils\CloningRegistryTrait;
|
|||||||
use pocketmine\world\sound\AmethystBlockChimeSound;
|
use pocketmine\world\sound\AmethystBlockChimeSound;
|
||||||
use pocketmine\world\sound\BlockPunchSound;
|
use pocketmine\world\sound\BlockPunchSound;
|
||||||
use function mb_strtolower;
|
use function mb_strtolower;
|
||||||
|
use function strtolower;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* This doc-block is generated automatically, do not modify it manually.
|
||||||
@ -1140,13 +1141,13 @@ final class VanillaBlocks{
|
|||||||
});
|
});
|
||||||
$saplingTypeInfo = new Info(BreakInfo::instant(), [Tags::POTTABLE_PLANTS]);
|
$saplingTypeInfo = new Info(BreakInfo::instant(), [Tags::POTTABLE_PLANTS]);
|
||||||
|
|
||||||
foreach(SaplingType::getAll() as $saplingType){
|
foreach(SaplingType::cases() as $saplingType){
|
||||||
$name = $saplingType->getDisplayName();
|
$name = $saplingType->getDisplayName();
|
||||||
self::register($saplingType->name() . "_sapling", new Sapling(WoodLikeBlockIdHelper::getSaplingIdentifier($saplingType), $name . " Sapling", $saplingTypeInfo, $saplingType));
|
self::register(strtolower($saplingType->name) . "_sapling", new Sapling(WoodLikeBlockIdHelper::getSaplingIdentifier($saplingType), $name . " Sapling", $saplingTypeInfo, $saplingType));
|
||||||
}
|
}
|
||||||
foreach(LeavesType::getAll() as $leavesType){
|
foreach(LeavesType::cases() as $leavesType){
|
||||||
$name = $leavesType->getDisplayName();
|
$name = $leavesType->getDisplayName();
|
||||||
self::register($leavesType->name() . "_leaves", new Leaves(WoodLikeBlockIdHelper::getLeavesIdentifier($leavesType), $name . " Leaves", $leavesBreakInfo, $leavesType));
|
self::register(strtolower($leavesType->name) . "_leaves", new Leaves(WoodLikeBlockIdHelper::getLeavesIdentifier($leavesType), $name . " Leaves", $leavesBreakInfo, $leavesType));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sandstoneBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD()));
|
$sandstoneBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD()));
|
||||||
@ -1262,9 +1263,9 @@ final class VanillaBlocks{
|
|||||||
$woodenButtonBreakInfo = new Info(BreakInfo::axe(0.5));
|
$woodenButtonBreakInfo = new Info(BreakInfo::axe(0.5));
|
||||||
$woodenPressurePlateBreakInfo = new Info(BreakInfo::axe(0.5));
|
$woodenPressurePlateBreakInfo = new Info(BreakInfo::axe(0.5));
|
||||||
|
|
||||||
foreach(WoodType::getAll() as $woodType){
|
foreach(WoodType::cases() as $woodType){
|
||||||
$name = $woodType->getDisplayName();
|
$name = $woodType->getDisplayName();
|
||||||
$idName = fn(string $suffix) => $woodType->name() . "_" . $suffix;
|
$idName = fn(string $suffix) => strtolower($woodType->name) . "_" . $suffix;
|
||||||
|
|
||||||
self::register($idName(mb_strtolower($woodType->getStandardLogSuffix() ?? "log", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getLogIdentifier($woodType), $name . " " . ($woodType->getStandardLogSuffix() ?? "Log"), $logBreakInfo, $woodType));
|
self::register($idName(mb_strtolower($woodType->getStandardLogSuffix() ?? "log", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getLogIdentifier($woodType), $name . " " . ($woodType->getStandardLogSuffix() ?? "Log"), $logBreakInfo, $woodType));
|
||||||
self::register($idName(mb_strtolower($woodType->getAllSidedLogSuffix() ?? "wood", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getAllSidedLogIdentifier($woodType), $name . " " . ($woodType->getAllSidedLogSuffix() ?? "Wood"), $logBreakInfo, $woodType));
|
self::register($idName(mb_strtolower($woodType->getAllSidedLogSuffix() ?? "wood", 'US-ASCII')), new Wood(WoodLikeBlockIdHelper::getAllSidedLogIdentifier($woodType), $name . " " . ($woodType->getAllSidedLogSuffix() ?? "Wood"), $logBreakInfo, $woodType));
|
||||||
|
@ -101,9 +101,9 @@ class Wall extends Transparent{
|
|||||||
|
|
||||||
foreach(Facing::HORIZONTAL as $facing){
|
foreach(Facing::HORIZONTAL as $facing){
|
||||||
$block = $this->getSide($facing);
|
$block = $this->getSide($facing);
|
||||||
if($block instanceof static || $block instanceof FenceGate || $block instanceof Thin || $block->getSupportType(Facing::opposite($facing))->equals(SupportType::FULL())){
|
if($block instanceof static || $block instanceof FenceGate || $block instanceof Thin || $block->getSupportType(Facing::opposite($facing)) === SupportType::FULL){
|
||||||
if(!isset($this->connections[$facing])){
|
if(!isset($this->connections[$facing])){
|
||||||
$this->connections[$facing] = WallConnectionType::SHORT();
|
$this->connections[$facing] = WallConnectionType::SHORT;
|
||||||
$changed++;
|
$changed++;
|
||||||
}
|
}
|
||||||
}elseif(isset($this->connections[$facing])){
|
}elseif(isset($this->connections[$facing])){
|
||||||
@ -152,6 +152,6 @@ class Wall extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportType(int $facing) : SupportType{
|
public function getSupportType(int $facing) : SupportType{
|
||||||
return Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE();
|
return Facing::axis($facing) === Axis::Y ? SupportType::CENTER : SupportType::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,110 +48,103 @@ use pocketmine\utils\AssumptionFailedError;
|
|||||||
final class WoodLikeBlockIdHelper{
|
final class WoodLikeBlockIdHelper{
|
||||||
|
|
||||||
public static function getPlanksIdentifier(WoodType $type) : BID{
|
public static function getPlanksIdentifier(WoodType $type) : BID{
|
||||||
return new BID(match($type->id()){
|
return new BID(match($type){
|
||||||
WoodType::OAK()->id() => Ids::OAK_PLANKS,
|
WoodType::OAK => Ids::OAK_PLANKS,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_PLANKS,
|
WoodType::SPRUCE => Ids::SPRUCE_PLANKS,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_PLANKS,
|
WoodType::BIRCH => Ids::BIRCH_PLANKS,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_PLANKS,
|
WoodType::JUNGLE => Ids::JUNGLE_PLANKS,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_PLANKS,
|
WoodType::ACACIA => Ids::ACACIA_PLANKS,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_PLANKS,
|
WoodType::DARK_OAK => Ids::DARK_OAK_PLANKS,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_PLANKS,
|
WoodType::MANGROVE => Ids::MANGROVE_PLANKS,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_PLANKS,
|
WoodType::CRIMSON => Ids::CRIMSON_PLANKS,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_PLANKS,
|
WoodType::WARPED => Ids::WARPED_PLANKS,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_PLANKS,
|
WoodType::CHERRY => Ids::CHERRY_PLANKS,
|
||||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFenceIdentifier(WoodType $type) : BID{
|
public static function getFenceIdentifier(WoodType $type) : BID{
|
||||||
return new BID(match($type->id()){
|
return new BID(match($type){
|
||||||
WoodType::OAK()->id() => Ids::OAK_FENCE,
|
WoodType::OAK => Ids::OAK_FENCE,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_FENCE,
|
WoodType::SPRUCE => Ids::SPRUCE_FENCE,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_FENCE,
|
WoodType::BIRCH => Ids::BIRCH_FENCE,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_FENCE,
|
WoodType::JUNGLE => Ids::JUNGLE_FENCE,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_FENCE,
|
WoodType::ACACIA => Ids::ACACIA_FENCE,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_FENCE,
|
WoodType::DARK_OAK => Ids::DARK_OAK_FENCE,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_FENCE,
|
WoodType::MANGROVE => Ids::MANGROVE_FENCE,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_FENCE,
|
WoodType::CRIMSON => Ids::CRIMSON_FENCE,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_FENCE,
|
WoodType::WARPED => Ids::WARPED_FENCE,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_FENCE,
|
WoodType::CHERRY => Ids::CHERRY_FENCE,
|
||||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSlabIdentifier(WoodType $type) : BID{
|
public static function getSlabIdentifier(WoodType $type) : BID{
|
||||||
return new BID(match($type->id()){
|
return new BID(match($type){
|
||||||
WoodType::OAK()->id() => Ids::OAK_SLAB,
|
WoodType::OAK => Ids::OAK_SLAB,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_SLAB,
|
WoodType::SPRUCE => Ids::SPRUCE_SLAB,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_SLAB,
|
WoodType::BIRCH => Ids::BIRCH_SLAB,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_SLAB,
|
WoodType::JUNGLE => Ids::JUNGLE_SLAB,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_SLAB,
|
WoodType::ACACIA => Ids::ACACIA_SLAB,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_SLAB,
|
WoodType::DARK_OAK => Ids::DARK_OAK_SLAB,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_SLAB,
|
WoodType::MANGROVE => Ids::MANGROVE_SLAB,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_SLAB,
|
WoodType::CRIMSON => Ids::CRIMSON_SLAB,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_SLAB,
|
WoodType::WARPED => Ids::WARPED_SLAB,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_SLAB,
|
WoodType::CHERRY => Ids::CHERRY_SLAB,
|
||||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getLogIdentifier(WoodType $treeType) : BID{
|
public static function getLogIdentifier(WoodType $treeType) : BID{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_LOG,
|
WoodType::OAK => Ids::OAK_LOG,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_LOG,
|
WoodType::SPRUCE => Ids::SPRUCE_LOG,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_LOG,
|
WoodType::BIRCH => Ids::BIRCH_LOG,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_LOG,
|
WoodType::JUNGLE => Ids::JUNGLE_LOG,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_LOG,
|
WoodType::ACACIA => Ids::ACACIA_LOG,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_LOG,
|
WoodType::DARK_OAK => Ids::DARK_OAK_LOG,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_LOG,
|
WoodType::MANGROVE => Ids::MANGROVE_LOG,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_STEM,
|
WoodType::CRIMSON => Ids::CRIMSON_STEM,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_STEM,
|
WoodType::WARPED => Ids::WARPED_STEM,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_LOG,
|
WoodType::CHERRY => Ids::CHERRY_LOG,
|
||||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllSidedLogIdentifier(WoodType $treeType) : BID{
|
public static function getAllSidedLogIdentifier(WoodType $treeType) : BID{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_WOOD,
|
WoodType::OAK => Ids::OAK_WOOD,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_WOOD,
|
WoodType::SPRUCE => Ids::SPRUCE_WOOD,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_WOOD,
|
WoodType::BIRCH => Ids::BIRCH_WOOD,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_WOOD,
|
WoodType::JUNGLE => Ids::JUNGLE_WOOD,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_WOOD,
|
WoodType::ACACIA => Ids::ACACIA_WOOD,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_WOOD,
|
WoodType::DARK_OAK => Ids::DARK_OAK_WOOD,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_WOOD,
|
WoodType::MANGROVE => Ids::MANGROVE_WOOD,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_HYPHAE,
|
WoodType::CRIMSON => Ids::CRIMSON_HYPHAE,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_HYPHAE,
|
WoodType::WARPED => Ids::WARPED_HYPHAE,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_WOOD,
|
WoodType::CHERRY => Ids::CHERRY_WOOD,
|
||||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getLeavesIdentifier(LeavesType $leavesType) : BID{
|
public static function getLeavesIdentifier(LeavesType $leavesType) : BID{
|
||||||
return new BID(match($leavesType->id()){
|
return new BID(match($leavesType){
|
||||||
LeavesType::OAK()->id() => Ids::OAK_LEAVES,
|
LeavesType::OAK => Ids::OAK_LEAVES,
|
||||||
LeavesType::SPRUCE()->id() => Ids::SPRUCE_LEAVES,
|
LeavesType::SPRUCE => Ids::SPRUCE_LEAVES,
|
||||||
LeavesType::BIRCH()->id() => Ids::BIRCH_LEAVES,
|
LeavesType::BIRCH => Ids::BIRCH_LEAVES,
|
||||||
LeavesType::JUNGLE()->id() => Ids::JUNGLE_LEAVES,
|
LeavesType::JUNGLE => Ids::JUNGLE_LEAVES,
|
||||||
LeavesType::ACACIA()->id() => Ids::ACACIA_LEAVES,
|
LeavesType::ACACIA => Ids::ACACIA_LEAVES,
|
||||||
LeavesType::DARK_OAK()->id() => Ids::DARK_OAK_LEAVES,
|
LeavesType::DARK_OAK => Ids::DARK_OAK_LEAVES,
|
||||||
LeavesType::MANGROVE()->id() => Ids::MANGROVE_LEAVES,
|
LeavesType::MANGROVE => Ids::MANGROVE_LEAVES,
|
||||||
LeavesType::AZALEA()->id() => Ids::AZALEA_LEAVES,
|
LeavesType::AZALEA => Ids::AZALEA_LEAVES,
|
||||||
LeavesType::FLOWERING_AZALEA()->id() => Ids::FLOWERING_AZALEA_LEAVES,
|
LeavesType::FLOWERING_AZALEA => Ids::FLOWERING_AZALEA_LEAVES,
|
||||||
LeavesType::CHERRY()->id() => Ids::CHERRY_LEAVES,
|
LeavesType::CHERRY => Ids::CHERRY_LEAVES,
|
||||||
default => throw new AssumptionFailedError("All leaves types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSaplingIdentifier(SaplingType $treeType) : BID{
|
public static function getSaplingIdentifier(SaplingType $treeType) : BID{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
SaplingType::OAK()->id() => Ids::OAK_SAPLING,
|
SaplingType::OAK => Ids::OAK_SAPLING,
|
||||||
SaplingType::SPRUCE()->id() => Ids::SPRUCE_SAPLING,
|
SaplingType::SPRUCE => Ids::SPRUCE_SAPLING,
|
||||||
SaplingType::BIRCH()->id() => Ids::BIRCH_SAPLING,
|
SaplingType::BIRCH => Ids::BIRCH_SAPLING,
|
||||||
SaplingType::JUNGLE()->id() => Ids::JUNGLE_SAPLING,
|
SaplingType::JUNGLE => Ids::JUNGLE_SAPLING,
|
||||||
SaplingType::ACACIA()->id() => Ids::ACACIA_SAPLING,
|
SaplingType::ACACIA => Ids::ACACIA_SAPLING,
|
||||||
SaplingType::DARK_OAK()->id() => Ids::DARK_OAK_SAPLING,
|
SaplingType::DARK_OAK => Ids::DARK_OAK_SAPLING,
|
||||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,62 +153,62 @@ final class WoodLikeBlockIdHelper{
|
|||||||
* @phpstan-return array{BID, BID, \Closure() : \pocketmine\item\Item}
|
* @phpstan-return array{BID, BID, \Closure() : \pocketmine\item\Item}
|
||||||
*/
|
*/
|
||||||
public static function getSignInfo(WoodType $treeType) : array{
|
public static function getSignInfo(WoodType $treeType) : array{
|
||||||
switch($treeType->id()){
|
switch($treeType){
|
||||||
case WoodType::OAK()->id():
|
case WoodType::OAK:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::OAK_SIGN, TileSign::class),
|
new BID(Ids::OAK_SIGN, TileSign::class),
|
||||||
new BID(Ids::OAK_WALL_SIGN, TileSign::class),
|
new BID(Ids::OAK_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::OAK_SIGN()
|
fn() => VanillaItems::OAK_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::SPRUCE()->id():
|
case WoodType::SPRUCE:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::SPRUCE_SIGN, TileSign::class),
|
new BID(Ids::SPRUCE_SIGN, TileSign::class),
|
||||||
new BID(Ids::SPRUCE_WALL_SIGN, TileSign::class),
|
new BID(Ids::SPRUCE_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::SPRUCE_SIGN()
|
fn() => VanillaItems::SPRUCE_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::BIRCH()->id():
|
case WoodType::BIRCH:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::BIRCH_SIGN, TileSign::class),
|
new BID(Ids::BIRCH_SIGN, TileSign::class),
|
||||||
new BID(Ids::BIRCH_WALL_SIGN, TileSign::class),
|
new BID(Ids::BIRCH_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::BIRCH_SIGN()
|
fn() => VanillaItems::BIRCH_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::JUNGLE()->id():
|
case WoodType::JUNGLE:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::JUNGLE_SIGN, TileSign::class),
|
new BID(Ids::JUNGLE_SIGN, TileSign::class),
|
||||||
new BID(Ids::JUNGLE_WALL_SIGN, TileSign::class),
|
new BID(Ids::JUNGLE_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::JUNGLE_SIGN()
|
fn() => VanillaItems::JUNGLE_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::ACACIA()->id():
|
case WoodType::ACACIA:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::ACACIA_SIGN, TileSign::class),
|
new BID(Ids::ACACIA_SIGN, TileSign::class),
|
||||||
new BID(Ids::ACACIA_WALL_SIGN, TileSign::class),
|
new BID(Ids::ACACIA_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::ACACIA_SIGN()
|
fn() => VanillaItems::ACACIA_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::DARK_OAK()->id():
|
case WoodType::DARK_OAK:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::DARK_OAK_SIGN, TileSign::class),
|
new BID(Ids::DARK_OAK_SIGN, TileSign::class),
|
||||||
new BID(Ids::DARK_OAK_WALL_SIGN, TileSign::class),
|
new BID(Ids::DARK_OAK_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::DARK_OAK_SIGN()
|
fn() => VanillaItems::DARK_OAK_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::MANGROVE()->id():
|
case WoodType::MANGROVE:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::MANGROVE_SIGN, TileSign::class),
|
new BID(Ids::MANGROVE_SIGN, TileSign::class),
|
||||||
new BID(Ids::MANGROVE_WALL_SIGN, TileSign::class),
|
new BID(Ids::MANGROVE_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::MANGROVE_SIGN()
|
fn() => VanillaItems::MANGROVE_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::CRIMSON()->id():
|
case WoodType::CRIMSON:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::CRIMSON_SIGN, TileSign::class),
|
new BID(Ids::CRIMSON_SIGN, TileSign::class),
|
||||||
new BID(Ids::CRIMSON_WALL_SIGN, TileSign::class),
|
new BID(Ids::CRIMSON_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::CRIMSON_SIGN()
|
fn() => VanillaItems::CRIMSON_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::WARPED()->id():
|
case WoodType::WARPED:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::WARPED_SIGN, TileSign::class),
|
new BID(Ids::WARPED_SIGN, TileSign::class),
|
||||||
new BID(Ids::WARPED_WALL_SIGN, TileSign::class),
|
new BID(Ids::WARPED_WALL_SIGN, TileSign::class),
|
||||||
fn() => VanillaItems::WARPED_SIGN()
|
fn() => VanillaItems::WARPED_SIGN()
|
||||||
];
|
];
|
||||||
case WoodType::CHERRY()->id():
|
case WoodType::CHERRY:
|
||||||
return [
|
return [
|
||||||
new BID(Ids::CHERRY_SIGN, TileSign::class),
|
new BID(Ids::CHERRY_SIGN, TileSign::class),
|
||||||
new BID(Ids::CHERRY_WALL_SIGN, TileSign::class),
|
new BID(Ids::CHERRY_WALL_SIGN, TileSign::class),
|
||||||
@ -226,98 +219,92 @@ final class WoodLikeBlockIdHelper{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getTrapdoorIdentifier(WoodType $treeType) : BlockIdentifier{
|
public static function getTrapdoorIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_TRAPDOOR,
|
WoodType::OAK => Ids::OAK_TRAPDOOR,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_TRAPDOOR,
|
WoodType::SPRUCE => Ids::SPRUCE_TRAPDOOR,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_TRAPDOOR,
|
WoodType::BIRCH => Ids::BIRCH_TRAPDOOR,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_TRAPDOOR,
|
WoodType::JUNGLE => Ids::JUNGLE_TRAPDOOR,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_TRAPDOOR,
|
WoodType::ACACIA => Ids::ACACIA_TRAPDOOR,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_TRAPDOOR,
|
WoodType::DARK_OAK => Ids::DARK_OAK_TRAPDOOR,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_TRAPDOOR,
|
WoodType::MANGROVE => Ids::MANGROVE_TRAPDOOR,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_TRAPDOOR,
|
WoodType::CRIMSON => Ids::CRIMSON_TRAPDOOR,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_TRAPDOOR,
|
WoodType::WARPED => Ids::WARPED_TRAPDOOR,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_TRAPDOOR,
|
WoodType::CHERRY => Ids::CHERRY_TRAPDOOR,
|
||||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getButtonIdentifier(WoodType $treeType) : BlockIdentifier{
|
public static function getButtonIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_BUTTON,
|
WoodType::OAK => Ids::OAK_BUTTON,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_BUTTON,
|
WoodType::SPRUCE => Ids::SPRUCE_BUTTON,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_BUTTON,
|
WoodType::BIRCH => Ids::BIRCH_BUTTON,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_BUTTON,
|
WoodType::JUNGLE => Ids::JUNGLE_BUTTON,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_BUTTON,
|
WoodType::ACACIA => Ids::ACACIA_BUTTON,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_BUTTON,
|
WoodType::DARK_OAK => Ids::DARK_OAK_BUTTON,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_BUTTON,
|
WoodType::MANGROVE => Ids::MANGROVE_BUTTON,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_BUTTON,
|
WoodType::CRIMSON => Ids::CRIMSON_BUTTON,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_BUTTON,
|
WoodType::WARPED => Ids::WARPED_BUTTON,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_BUTTON,
|
WoodType::CHERRY => Ids::CHERRY_BUTTON,
|
||||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPressurePlateIdentifier(WoodType $treeType) : BlockIdentifier{
|
public static function getPressurePlateIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_PRESSURE_PLATE,
|
WoodType::OAK => Ids::OAK_PRESSURE_PLATE,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_PRESSURE_PLATE,
|
WoodType::SPRUCE => Ids::SPRUCE_PRESSURE_PLATE,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_PRESSURE_PLATE,
|
WoodType::BIRCH => Ids::BIRCH_PRESSURE_PLATE,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_PRESSURE_PLATE,
|
WoodType::JUNGLE => Ids::JUNGLE_PRESSURE_PLATE,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_PRESSURE_PLATE,
|
WoodType::ACACIA => Ids::ACACIA_PRESSURE_PLATE,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_PRESSURE_PLATE,
|
WoodType::DARK_OAK => Ids::DARK_OAK_PRESSURE_PLATE,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_PRESSURE_PLATE,
|
WoodType::MANGROVE => Ids::MANGROVE_PRESSURE_PLATE,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_PRESSURE_PLATE,
|
WoodType::CRIMSON => Ids::CRIMSON_PRESSURE_PLATE,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_PRESSURE_PLATE,
|
WoodType::WARPED => Ids::WARPED_PRESSURE_PLATE,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_PRESSURE_PLATE,
|
WoodType::CHERRY => Ids::CHERRY_PRESSURE_PLATE,
|
||||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDoorIdentifier(WoodType $treeType) : BlockIdentifier{
|
public static function getDoorIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_DOOR,
|
WoodType::OAK => Ids::OAK_DOOR,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_DOOR,
|
WoodType::SPRUCE => Ids::SPRUCE_DOOR,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_DOOR,
|
WoodType::BIRCH => Ids::BIRCH_DOOR,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_DOOR,
|
WoodType::JUNGLE => Ids::JUNGLE_DOOR,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_DOOR,
|
WoodType::ACACIA => Ids::ACACIA_DOOR,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_DOOR,
|
WoodType::DARK_OAK => Ids::DARK_OAK_DOOR,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_DOOR,
|
WoodType::MANGROVE => Ids::MANGROVE_DOOR,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_DOOR,
|
WoodType::CRIMSON => Ids::CRIMSON_DOOR,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_DOOR,
|
WoodType::WARPED => Ids::WARPED_DOOR,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_DOOR,
|
WoodType::CHERRY => Ids::CHERRY_DOOR,
|
||||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFenceGateIdentifier(WoodType $treeType) : BlockIdentifier{
|
public static function getFenceGateIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_FENCE_GATE,
|
WoodType::OAK => Ids::OAK_FENCE_GATE,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_FENCE_GATE,
|
WoodType::SPRUCE => Ids::SPRUCE_FENCE_GATE,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_FENCE_GATE,
|
WoodType::BIRCH => Ids::BIRCH_FENCE_GATE,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_FENCE_GATE,
|
WoodType::JUNGLE => Ids::JUNGLE_FENCE_GATE,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_FENCE_GATE,
|
WoodType::ACACIA => Ids::ACACIA_FENCE_GATE,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_FENCE_GATE,
|
WoodType::DARK_OAK => Ids::DARK_OAK_FENCE_GATE,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_FENCE_GATE,
|
WoodType::MANGROVE => Ids::MANGROVE_FENCE_GATE,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_FENCE_GATE,
|
WoodType::CRIMSON => Ids::CRIMSON_FENCE_GATE,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_FENCE_GATE,
|
WoodType::WARPED => Ids::WARPED_FENCE_GATE,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_FENCE_GATE,
|
WoodType::CHERRY => Ids::CHERRY_FENCE_GATE,
|
||||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getStairsIdentifier(WoodType $treeType) : BlockIdentifier{
|
public static function getStairsIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||||
return new BID(match($treeType->id()){
|
return new BID(match($treeType){
|
||||||
WoodType::OAK()->id() => Ids::OAK_STAIRS,
|
WoodType::OAK => Ids::OAK_STAIRS,
|
||||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_STAIRS,
|
WoodType::SPRUCE => Ids::SPRUCE_STAIRS,
|
||||||
WoodType::BIRCH()->id() => Ids::BIRCH_STAIRS,
|
WoodType::BIRCH => Ids::BIRCH_STAIRS,
|
||||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_STAIRS,
|
WoodType::JUNGLE => Ids::JUNGLE_STAIRS,
|
||||||
WoodType::ACACIA()->id() => Ids::ACACIA_STAIRS,
|
WoodType::ACACIA => Ids::ACACIA_STAIRS,
|
||||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_STAIRS,
|
WoodType::DARK_OAK => Ids::DARK_OAK_STAIRS,
|
||||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_STAIRS,
|
WoodType::MANGROVE => Ids::MANGROVE_STAIRS,
|
||||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_STAIRS,
|
WoodType::CRIMSON => Ids::CRIMSON_STAIRS,
|
||||||
WoodType::WARPED()->id() => Ids::WARPED_STAIRS,
|
WoodType::WARPED => Ids::WARPED_STAIRS,
|
||||||
WoodType::CHERRY()->id() => Ids::CHERRY_STAIRS,
|
WoodType::CHERRY => Ids::CHERRY_STAIRS,
|
||||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,8 @@ namespace pocketmine\block\tile;
|
|||||||
use pocketmine\block\utils\MobHeadType;
|
use pocketmine\block\utils\MobHeadType;
|
||||||
use pocketmine\data\bedrock\MobHeadTypeIdMap;
|
use pocketmine\data\bedrock\MobHeadTypeIdMap;
|
||||||
use pocketmine\data\SavedDataLoadingException;
|
use pocketmine\data\SavedDataLoadingException;
|
||||||
use pocketmine\math\Vector3;
|
|
||||||
use pocketmine\nbt\tag\ByteTag;
|
use pocketmine\nbt\tag\ByteTag;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\world\World;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -42,14 +40,9 @@ class MobHead extends Spawnable{
|
|||||||
private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte
|
private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte
|
||||||
private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int
|
private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int
|
||||||
|
|
||||||
private MobHeadType $mobHeadType;
|
private MobHeadType $mobHeadType = MobHeadType::SKELETON;
|
||||||
private int $rotation = 0;
|
private int $rotation = 0;
|
||||||
|
|
||||||
public function __construct(World $world, Vector3 $pos){
|
|
||||||
$this->mobHeadType = MobHeadType::SKELETON();
|
|
||||||
parent::__construct($world, $pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readSaveData(CompoundTag $nbt) : void{
|
public function readSaveData(CompoundTag $nbt) : void{
|
||||||
if(($skullTypeTag = $nbt->getTag(self::TAG_SKULL_TYPE)) instanceof ByteTag){
|
if(($skullTypeTag = $nbt->getTag(self::TAG_SKULL_TYPE)) instanceof ByteTag){
|
||||||
$mobHeadType = MobHeadTypeIdMap::getInstance()->fromId($skullTypeTag->getValue());
|
$mobHeadType = MobHeadTypeIdMap::getInstance()->fromId($skullTypeTag->getValue());
|
||||||
|
@ -23,13 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static BannerPatternType BORDER()
|
* @method static BannerPatternType BORDER()
|
||||||
* @method static BannerPatternType BRICKS()
|
* @method static BannerPatternType BRICKS()
|
||||||
@ -70,49 +68,45 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static BannerPatternType TRIANGLE_BOTTOM()
|
* @method static BannerPatternType TRIANGLE_BOTTOM()
|
||||||
* @method static BannerPatternType TRIANGLE_TOP()
|
* @method static BannerPatternType TRIANGLE_TOP()
|
||||||
*/
|
*/
|
||||||
final class BannerPatternType{
|
enum BannerPatternType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case BORDER;
|
||||||
self::registerAll(
|
case BRICKS;
|
||||||
new self("border"),
|
case CIRCLE;
|
||||||
new self("bricks"),
|
case CREEPER;
|
||||||
new self("circle"),
|
case CROSS;
|
||||||
new self("creeper"),
|
case CURLY_BORDER;
|
||||||
new self("cross"),
|
case DIAGONAL_LEFT;
|
||||||
new self("curly_border"),
|
case DIAGONAL_RIGHT;
|
||||||
new self("diagonal_left"),
|
case DIAGONAL_UP_LEFT;
|
||||||
new self("diagonal_right"),
|
case DIAGONAL_UP_RIGHT;
|
||||||
new self("diagonal_up_left"),
|
case FLOWER;
|
||||||
new self("diagonal_up_right"),
|
case GRADIENT;
|
||||||
new self("flower"),
|
case GRADIENT_UP;
|
||||||
new self("gradient"),
|
case HALF_HORIZONTAL;
|
||||||
new self("gradient_up"),
|
case HALF_HORIZONTAL_BOTTOM;
|
||||||
new self("half_horizontal"),
|
case HALF_VERTICAL;
|
||||||
new self("half_horizontal_bottom"),
|
case HALF_VERTICAL_RIGHT;
|
||||||
new self("half_vertical"),
|
case MOJANG;
|
||||||
new self("half_vertical_right"),
|
case RHOMBUS;
|
||||||
new self("mojang"),
|
case SKULL;
|
||||||
new self("rhombus"),
|
case SMALL_STRIPES;
|
||||||
new self("skull"),
|
case SQUARE_BOTTOM_LEFT;
|
||||||
new self("small_stripes"),
|
case SQUARE_BOTTOM_RIGHT;
|
||||||
new self("square_bottom_left"),
|
case SQUARE_TOP_LEFT;
|
||||||
new self("square_bottom_right"),
|
case SQUARE_TOP_RIGHT;
|
||||||
new self("square_top_left"),
|
case STRAIGHT_CROSS;
|
||||||
new self("square_top_right"),
|
case STRIPE_BOTTOM;
|
||||||
new self("straight_cross"),
|
case STRIPE_CENTER;
|
||||||
new self("stripe_bottom"),
|
case STRIPE_DOWNLEFT;
|
||||||
new self("stripe_center"),
|
case STRIPE_DOWNRIGHT;
|
||||||
new self("stripe_downleft"),
|
case STRIPE_LEFT;
|
||||||
new self("stripe_downright"),
|
case STRIPE_MIDDLE;
|
||||||
new self("stripe_left"),
|
case STRIPE_RIGHT;
|
||||||
new self("stripe_middle"),
|
case STRIPE_TOP;
|
||||||
new self("stripe_right"),
|
case TRIANGLE_BOTTOM;
|
||||||
new self("stripe_top"),
|
case TRIANGLE_TOP;
|
||||||
new self("triangle_bottom"),
|
case TRIANGLES_BOTTOM;
|
||||||
new self("triangle_top"),
|
case TRIANGLES_TOP;
|
||||||
new self("triangles_bottom"),
|
|
||||||
new self("triangles_top")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,28 +23,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static BellAttachmentType CEILING()
|
* @method static BellAttachmentType CEILING()
|
||||||
* @method static BellAttachmentType FLOOR()
|
* @method static BellAttachmentType FLOOR()
|
||||||
* @method static BellAttachmentType ONE_WALL()
|
* @method static BellAttachmentType ONE_WALL()
|
||||||
* @method static BellAttachmentType TWO_WALLS()
|
* @method static BellAttachmentType TWO_WALLS()
|
||||||
*/
|
*/
|
||||||
final class BellAttachmentType{
|
enum BellAttachmentType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case CEILING;
|
||||||
self::registerAll(
|
case FLOOR;
|
||||||
new self("ceiling"),
|
case ONE_WALL;
|
||||||
new self("floor"),
|
case TWO_WALLS;
|
||||||
new self("one_wall"),
|
|
||||||
new self("two_walls")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,37 +24,31 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\block\inventory\BrewingStandInventory;
|
use pocketmine\block\inventory\BrewingStandInventory;
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static BrewingStandSlot EAST()
|
* @method static BrewingStandSlot EAST()
|
||||||
* @method static BrewingStandSlot NORTHWEST()
|
* @method static BrewingStandSlot NORTHWEST()
|
||||||
* @method static BrewingStandSlot SOUTHWEST()
|
* @method static BrewingStandSlot SOUTHWEST()
|
||||||
*/
|
*/
|
||||||
final class BrewingStandSlot{
|
enum BrewingStandSlot{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
__construct as Enum___construct;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case EAST;
|
||||||
self::registerAll(
|
case NORTHWEST;
|
||||||
new self("east", BrewingStandInventory::SLOT_BOTTLE_LEFT),
|
case SOUTHWEST;
|
||||||
new self("northwest", BrewingStandInventory::SLOT_BOTTLE_MIDDLE),
|
|
||||||
new self("southwest", BrewingStandInventory::SLOT_BOTTLE_RIGHT)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct(string $enumName, private int $slotNumber){
|
|
||||||
$this->Enum___construct($enumName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the brewing stand inventory slot number associated with this visual slot.
|
* Returns the brewing stand inventory slot number associated with this visual slot.
|
||||||
*/
|
*/
|
||||||
public function getSlotNumber() : int{ return $this->slotNumber; }
|
public function getSlotNumber() : int{
|
||||||
|
return match($this){
|
||||||
|
self::EAST => BrewingStandInventory::SLOT_BOTTLE_LEFT,
|
||||||
|
self::NORTHWEST => BrewingStandInventory::SLOT_BOTTLE_MIDDLE,
|
||||||
|
self::SOUTHWEST => BrewingStandInventory::SLOT_BOTTLE_RIGHT
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,57 +23,30 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static CopperOxidation EXPOSED()
|
* @method static CopperOxidation EXPOSED()
|
||||||
* @method static CopperOxidation NONE()
|
* @method static CopperOxidation NONE()
|
||||||
* @method static CopperOxidation OXIDIZED()
|
* @method static CopperOxidation OXIDIZED()
|
||||||
* @method static CopperOxidation WEATHERED()
|
* @method static CopperOxidation WEATHERED()
|
||||||
*/
|
*/
|
||||||
final class CopperOxidation{
|
enum CopperOxidation : int{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
__construct as Enum___construct;
|
|
||||||
register as Enum_register;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case NONE = 0;
|
||||||
self::registerAll(
|
case EXPOSED = 1;
|
||||||
new self("none", 0),
|
case WEATHERED = 2;
|
||||||
new self("exposed", 1),
|
case OXIDIZED = 3;
|
||||||
new self("weathered", 2),
|
|
||||||
new self("oxidized", 3)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function register(self $member) : void{
|
|
||||||
self::Enum_register($member);
|
|
||||||
self::$levelMap[$member->value] = $member;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var self[]
|
|
||||||
* @phpstan-var array<int, self>
|
|
||||||
*/
|
|
||||||
private static array $levelMap = [];
|
|
||||||
|
|
||||||
private function __construct(
|
|
||||||
string $name,
|
|
||||||
private int $value
|
|
||||||
){
|
|
||||||
$this->Enum___construct($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrevious() : ?self{
|
public function getPrevious() : ?self{
|
||||||
return self::$levelMap[$this->value - 1] ?? null;
|
return self::tryFrom($this->value - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNext() : ?self{
|
public function getNext() : ?self{
|
||||||
return self::$levelMap[$this->value + 1] ?? null;
|
return self::tryFrom($this->value + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\block\BlockIdentifier;
|
|
||||||
use pocketmine\block\BlockTypeInfo;
|
|
||||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||||
use pocketmine\item\Axe;
|
use pocketmine\item\Axe;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
@ -36,14 +34,9 @@ use pocketmine\world\sound\CopperWaxRemoveSound;
|
|||||||
use pocketmine\world\sound\ScrapeSound;
|
use pocketmine\world\sound\ScrapeSound;
|
||||||
|
|
||||||
trait CopperTrait{
|
trait CopperTrait{
|
||||||
private CopperOxidation $oxidation;
|
private CopperOxidation $oxidation = CopperOxidation::NONE;
|
||||||
private bool $waxed = false;
|
private bool $waxed = false;
|
||||||
|
|
||||||
public function __construct(BlockIdentifier $identifier, string $name, BlockTypeInfo $typeInfo){
|
|
||||||
$this->oxidation = CopperOxidation::NONE();
|
|
||||||
parent::__construct($identifier, $name, $typeInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
public function describeBlockItemState(RuntimeDataDescriber $w) : void{
|
||||||
$w->copperOxidation($this->oxidation);
|
$w->copperOxidation($this->oxidation);
|
||||||
$w->bool($this->waxed);
|
$w->bool($this->waxed);
|
||||||
|
@ -23,13 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static CoralType BRAIN()
|
* @method static CoralType BRAIN()
|
||||||
* @method static CoralType BUBBLE()
|
* @method static CoralType BUBBLE()
|
||||||
@ -37,27 +35,22 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static CoralType HORN()
|
* @method static CoralType HORN()
|
||||||
* @method static CoralType TUBE()
|
* @method static CoralType TUBE()
|
||||||
*/
|
*/
|
||||||
final class CoralType{
|
enum CoralType{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
__construct as Enum___construct;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case TUBE;
|
||||||
self::registerAll(
|
case BRAIN;
|
||||||
new self("tube", "Tube"),
|
case BUBBLE;
|
||||||
new self("brain", "Brain"),
|
case FIRE;
|
||||||
new self("bubble", "Bubble"),
|
case HORN;
|
||||||
new self("fire", "Fire"),
|
|
||||||
new self("horn", "Horn"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct(
|
public function getDisplayName() : string{
|
||||||
string $name,
|
return match($this){
|
||||||
private string $displayName
|
self::TUBE => "Tube",
|
||||||
){
|
self::BRAIN => "Brain",
|
||||||
$this->Enum___construct($name);
|
self::BUBBLE => "Bubble",
|
||||||
|
self::FIRE => "Fire",
|
||||||
|
self::HORN => "Horn",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDisplayName() : string{ return $this->displayName; }
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ use pocketmine\block\Block;
|
|||||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||||
|
|
||||||
trait CoralTypeTrait{
|
trait CoralTypeTrait{
|
||||||
protected CoralType $coralType;
|
protected CoralType $coralType = CoralType::TUBE;
|
||||||
protected bool $dead = false;
|
protected bool $dead = false;
|
||||||
|
|
||||||
/** @see Block::describeBlockItemState() */
|
/** @see Block::describeBlockItemState() */
|
||||||
|
@ -23,26 +23,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static DirtType COARSE()
|
* @method static DirtType COARSE()
|
||||||
* @method static DirtType NORMAL()
|
* @method static DirtType NORMAL()
|
||||||
* @method static DirtType ROOTED()
|
* @method static DirtType ROOTED()
|
||||||
*/
|
*/
|
||||||
final class DirtType{
|
enum DirtType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case NORMAL;
|
||||||
self::registerAll(
|
case COARSE;
|
||||||
new self("normal"),
|
case ROOTED;
|
||||||
new self("coarse"),
|
|
||||||
new self("rooted")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,43 +23,30 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static DripleafState FULL_TILT()
|
* @method static DripleafState FULL_TILT()
|
||||||
* @method static DripleafState PARTIAL_TILT()
|
* @method static DripleafState PARTIAL_TILT()
|
||||||
* @method static DripleafState STABLE()
|
* @method static DripleafState STABLE()
|
||||||
* @method static DripleafState UNSTABLE()
|
* @method static DripleafState UNSTABLE()
|
||||||
*/
|
*/
|
||||||
final class DripleafState{
|
enum DripleafState{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
register as Enum_register;
|
|
||||||
__construct as Enum___construct;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case STABLE;
|
||||||
self::registerAll(
|
case UNSTABLE;
|
||||||
new self("stable", null),
|
case PARTIAL_TILT;
|
||||||
new self("unstable", 10),
|
case FULL_TILT;
|
||||||
new self("partial_tilt", 10),
|
|
||||||
new self("full_tilt", 100)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct(
|
|
||||||
string $enumName,
|
|
||||||
private ?int $scheduledUpdateDelayTicks
|
|
||||||
){
|
|
||||||
$this->Enum___construct($enumName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getScheduledUpdateDelayTicks() : ?int{
|
public function getScheduledUpdateDelayTicks() : ?int{
|
||||||
return $this->scheduledUpdateDelayTicks;
|
return match($this){
|
||||||
|
self::STABLE => null,
|
||||||
|
self::UNSTABLE, self::PARTIAL_TILT => 10,
|
||||||
|
self::FULL_TILT => 100,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,26 +23,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static FroglightType OCHRE()
|
* @method static FroglightType OCHRE()
|
||||||
* @method static FroglightType PEARLESCENT()
|
* @method static FroglightType PEARLESCENT()
|
||||||
* @method static FroglightType VERDANT()
|
* @method static FroglightType VERDANT()
|
||||||
*/
|
*/
|
||||||
final class FroglightType{
|
enum FroglightType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case OCHRE;
|
||||||
self::registerAll(
|
case PEARLESCENT;
|
||||||
new self("ochre"),
|
case VERDANT;
|
||||||
new self("pearlescent"),
|
|
||||||
new self("verdant")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static LeavesType ACACIA()
|
* @method static LeavesType ACACIA()
|
||||||
* @method static LeavesType AZALEA()
|
* @method static LeavesType AZALEA()
|
||||||
@ -42,35 +40,32 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static LeavesType OAK()
|
* @method static LeavesType OAK()
|
||||||
* @method static LeavesType SPRUCE()
|
* @method static LeavesType SPRUCE()
|
||||||
*/
|
*/
|
||||||
final class LeavesType{
|
enum LeavesType{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
register as Enum_register;
|
|
||||||
__construct as Enum___construct;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case OAK;
|
||||||
self::registerAll(
|
case SPRUCE;
|
||||||
new self("oak", "Oak"),
|
case BIRCH;
|
||||||
new self("spruce", "Spruce"),
|
case JUNGLE;
|
||||||
new self("birch", "Birch"),
|
case ACACIA;
|
||||||
new self("jungle", "Jungle"),
|
case DARK_OAK;
|
||||||
new self("acacia", "Acacia"),
|
case MANGROVE;
|
||||||
new self("dark_oak", "Dark Oak"),
|
case AZALEA;
|
||||||
new self("mangrove", "Mangrove"),
|
case FLOWERING_AZALEA;
|
||||||
new self("azalea", "Azalea"),
|
case CHERRY;
|
||||||
new self("flowering_azalea", "Flowering Azalea"),
|
|
||||||
new self("cherry", "Cherry")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct(
|
|
||||||
string $enumName,
|
|
||||||
private string $displayName
|
|
||||||
){
|
|
||||||
$this->Enum___construct($enumName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDisplayName() : string{
|
public function getDisplayName() : string{
|
||||||
return $this->displayName;
|
return match($this){
|
||||||
|
self::OAK => "Oak",
|
||||||
|
self::SPRUCE => "Spruce",
|
||||||
|
self::BIRCH => "Birch",
|
||||||
|
self::JUNGLE => "Jungle",
|
||||||
|
self::ACACIA => "Acacia",
|
||||||
|
self::DARK_OAK => "Dark Oak",
|
||||||
|
self::MANGROVE => "Mangrove",
|
||||||
|
self::AZALEA => "Azalea",
|
||||||
|
self::FLOWERING_AZALEA => "Flowering Azalea",
|
||||||
|
self::CHERRY => "Cherry"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,11 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static LeverFacing DOWN_AXIS_X()
|
* @method static LeverFacing DOWN_AXIS_X()
|
||||||
* @method static LeverFacing DOWN_AXIS_Z()
|
* @method static LeverFacing DOWN_AXIS_Z()
|
||||||
@ -41,27 +39,26 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static LeverFacing UP_AXIS_Z()
|
* @method static LeverFacing UP_AXIS_Z()
|
||||||
* @method static LeverFacing WEST()
|
* @method static LeverFacing WEST()
|
||||||
*/
|
*/
|
||||||
final class LeverFacing{
|
enum LeverFacing{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
__construct as Enum___construct;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case UP_AXIS_X;
|
||||||
self::registerAll(
|
case UP_AXIS_Z;
|
||||||
new self("up_axis_x", Facing::UP),
|
case DOWN_AXIS_X;
|
||||||
new self("up_axis_z", Facing::UP),
|
case DOWN_AXIS_Z;
|
||||||
new self("down_axis_x", Facing::DOWN),
|
case NORTH;
|
||||||
new self("down_axis_z", Facing::DOWN),
|
case EAST;
|
||||||
new self("north", Facing::NORTH),
|
case SOUTH;
|
||||||
new self("east", Facing::EAST),
|
case WEST;
|
||||||
new self("south", Facing::SOUTH),
|
|
||||||
new self("west", Facing::WEST),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct(string $enumName, private int $facing){
|
public function getFacing() : int{
|
||||||
$this->Enum___construct($enumName);
|
return match($this){
|
||||||
|
self::UP_AXIS_X, self::UP_AXIS_Z => Facing::UP,
|
||||||
|
self::DOWN_AXIS_X, self::DOWN_AXIS_Z => Facing::DOWN,
|
||||||
|
self::NORTH => Facing::NORTH,
|
||||||
|
self::EAST => Facing::EAST,
|
||||||
|
self::SOUTH => Facing::SOUTH,
|
||||||
|
self::WEST => Facing::WEST,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFacing() : int{ return $this->facing; }
|
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static MobHeadType CREEPER()
|
* @method static MobHeadType CREEPER()
|
||||||
* @method static MobHeadType DRAGON()
|
* @method static MobHeadType DRAGON()
|
||||||
@ -39,31 +37,26 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static MobHeadType WITHER_SKELETON()
|
* @method static MobHeadType WITHER_SKELETON()
|
||||||
* @method static MobHeadType ZOMBIE()
|
* @method static MobHeadType ZOMBIE()
|
||||||
*/
|
*/
|
||||||
final class MobHeadType{
|
enum MobHeadType{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
__construct as Enum___construct;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case SKELETON;
|
||||||
self::registerAll(
|
case WITHER_SKELETON;
|
||||||
new MobHeadType("skeleton", "Skeleton Skull"),
|
case ZOMBIE;
|
||||||
new MobHeadType("wither_skeleton", "Wither Skeleton Skull"),
|
case PLAYER;
|
||||||
new MobHeadType("zombie", "Zombie Head"),
|
case CREEPER;
|
||||||
new MobHeadType("player", "Player Head"),
|
case DRAGON;
|
||||||
new MobHeadType("creeper", "Creeper Head"),
|
case PIGLIN;
|
||||||
new MobHeadType("dragon", "Dragon Head"),
|
|
||||||
new MobHeadType("piglin", "Piglin Head")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct(
|
|
||||||
string $enumName,
|
|
||||||
private string $displayName
|
|
||||||
){
|
|
||||||
$this->Enum___construct($enumName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDisplayName() : string{
|
public function getDisplayName() : string{
|
||||||
return $this->displayName;
|
return match($this){
|
||||||
|
self::SKELETON => "Skeleton Skull",
|
||||||
|
self::WITHER_SKELETON => "Wither Skeleton Skull",
|
||||||
|
self::ZOMBIE => "Zombie Head",
|
||||||
|
self::PLAYER => "Player Head",
|
||||||
|
self::CREEPER => "Creeper Head",
|
||||||
|
self::DRAGON => "Dragon Head",
|
||||||
|
self::PIGLIN => "Piglin Head"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static MushroomBlockType ALL_CAP()
|
* @method static MushroomBlockType ALL_CAP()
|
||||||
* @method static MushroomBlockType CAP_EAST()
|
* @method static MushroomBlockType CAP_EAST()
|
||||||
@ -43,22 +41,18 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static MushroomBlockType CAP_WEST()
|
* @method static MushroomBlockType CAP_WEST()
|
||||||
* @method static MushroomBlockType PORES()
|
* @method static MushroomBlockType PORES()
|
||||||
*/
|
*/
|
||||||
final class MushroomBlockType{
|
enum MushroomBlockType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case PORES;
|
||||||
self::registerAll(
|
case CAP_NORTHWEST;
|
||||||
new self("PORES"),
|
case CAP_NORTH;
|
||||||
new self("CAP_NORTHWEST"),
|
case CAP_NORTHEAST;
|
||||||
new self("CAP_NORTH"),
|
case CAP_WEST;
|
||||||
new self("CAP_NORTHEAST"),
|
case CAP_MIDDLE;
|
||||||
new self("CAP_WEST"),
|
case CAP_EAST;
|
||||||
new self("CAP_MIDDLE"),
|
case CAP_SOUTHWEST;
|
||||||
new self("CAP_EAST"),
|
case CAP_SOUTH;
|
||||||
new self("CAP_SOUTHWEST"),
|
case CAP_SOUTHEAST;
|
||||||
new self("CAP_SOUTH"),
|
case ALL_CAP;
|
||||||
new self("CAP_SOUTHEAST"),
|
|
||||||
new self("ALL_CAP")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
use pocketmine\world\generator\object\TreeType;
|
use pocketmine\world\generator\object\TreeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static SaplingType ACACIA()
|
* @method static SaplingType ACACIA()
|
||||||
* @method static SaplingType BIRCH()
|
* @method static SaplingType BIRCH()
|
||||||
@ -39,33 +37,29 @@ use pocketmine\world\generator\object\TreeType;
|
|||||||
* @method static SaplingType OAK()
|
* @method static SaplingType OAK()
|
||||||
* @method static SaplingType SPRUCE()
|
* @method static SaplingType SPRUCE()
|
||||||
*/
|
*/
|
||||||
final class SaplingType{
|
enum SaplingType{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
__construct as Enum___construct;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function setup() : void{
|
case OAK;
|
||||||
self::registerAll(
|
case SPRUCE;
|
||||||
new self("oak", TreeType::OAK()),
|
case BIRCH;
|
||||||
new self("spruce", TreeType::SPRUCE()),
|
case JUNGLE;
|
||||||
new self("birch", TreeType::BIRCH()),
|
case ACACIA;
|
||||||
new self("jungle", TreeType::JUNGLE()),
|
case DARK_OAK;
|
||||||
new self("acacia", TreeType::ACACIA()),
|
|
||||||
new self("dark_oak", TreeType::DARK_OAK()),
|
|
||||||
//TODO: cherry
|
//TODO: cherry
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct(
|
public function getTreeType() : TreeType{
|
||||||
string $enumName,
|
return match($this){
|
||||||
private TreeType $treeType,
|
self::OAK => TreeType::OAK,
|
||||||
){
|
self::SPRUCE => TreeType::SPRUCE,
|
||||||
$this->Enum___construct($enumName);
|
self::BIRCH => TreeType::BIRCH,
|
||||||
|
self::JUNGLE => TreeType::JUNGLE,
|
||||||
|
self::ACACIA => TreeType::ACACIA,
|
||||||
|
self::DARK_OAK => TreeType::DARK_OAK,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTreeType() : TreeType{ return $this->treeType; }
|
|
||||||
|
|
||||||
public function getDisplayName() : string{
|
public function getDisplayName() : string{
|
||||||
return $this->treeType->getDisplayName();
|
return $this->getTreeType()->getDisplayName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,26 +23,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static SlabType BOTTOM()
|
* @method static SlabType BOTTOM()
|
||||||
* @method static SlabType DOUBLE()
|
* @method static SlabType DOUBLE()
|
||||||
* @method static SlabType TOP()
|
* @method static SlabType TOP()
|
||||||
*/
|
*/
|
||||||
final class SlabType{
|
enum SlabType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case BOTTOM;
|
||||||
self::registerAll(
|
case TOP;
|
||||||
new self("bottom"),
|
case DOUBLE;
|
||||||
new self("top"),
|
|
||||||
new self("double")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static StairShape INNER_LEFT()
|
* @method static StairShape INNER_LEFT()
|
||||||
* @method static StairShape INNER_RIGHT()
|
* @method static StairShape INNER_RIGHT()
|
||||||
@ -37,16 +35,12 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static StairShape OUTER_RIGHT()
|
* @method static StairShape OUTER_RIGHT()
|
||||||
* @method static StairShape STRAIGHT()
|
* @method static StairShape STRAIGHT()
|
||||||
*/
|
*/
|
||||||
final class StairShape{
|
enum StairShape{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case STRAIGHT;
|
||||||
self::registerAll(
|
case INNER_LEFT;
|
||||||
new self("straight"),
|
case INNER_RIGHT;
|
||||||
new self("inner_left"),
|
case OUTER_LEFT;
|
||||||
new self("inner_right"),
|
case OUTER_RIGHT;
|
||||||
new self("outer_left"),
|
|
||||||
new self("outer_right")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,36 +23,30 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static SupportType CENTER()
|
* @method static SupportType CENTER()
|
||||||
* @method static SupportType EDGE()
|
* @method static SupportType EDGE()
|
||||||
* @method static SupportType FULL()
|
* @method static SupportType FULL()
|
||||||
* @method static SupportType NONE()
|
* @method static SupportType NONE()
|
||||||
*/
|
*/
|
||||||
final class SupportType{
|
enum SupportType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case FULL;
|
||||||
self::registerAll(
|
case CENTER;
|
||||||
new self("full"),
|
case EDGE;
|
||||||
new self("center"),
|
case NONE;
|
||||||
new self("edge"),
|
|
||||||
new self("none")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasEdgeSupport() : bool{
|
public function hasEdgeSupport() : bool{
|
||||||
return $this->equals(self::EDGE()) || $this->equals(self::FULL());
|
return $this === self::EDGE || $this === self::FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasCenterSupport() : bool{
|
public function hasCenterSupport() : bool{
|
||||||
return $this->equals(self::CENTER()) || $this->equals(self::FULL());
|
return $this === self::CENTER || $this === self::FULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,24 +23,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static WallConnectionType SHORT()
|
* @method static WallConnectionType SHORT()
|
||||||
* @method static WallConnectionType TALL()
|
* @method static WallConnectionType TALL()
|
||||||
*/
|
*/
|
||||||
final class WallConnectionType{
|
enum WallConnectionType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case SHORT;
|
||||||
self::registerAll(
|
case TALL;
|
||||||
new self("short"),
|
|
||||||
new self("tall")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static WoodType ACACIA()
|
* @method static WoodType ACACIA()
|
||||||
* @method static WoodType BIRCH()
|
* @method static WoodType BIRCH()
|
||||||
@ -42,41 +40,44 @@ use pocketmine\utils\EnumTrait;
|
|||||||
* @method static WoodType SPRUCE()
|
* @method static WoodType SPRUCE()
|
||||||
* @method static WoodType WARPED()
|
* @method static WoodType WARPED()
|
||||||
*/
|
*/
|
||||||
final class WoodType{
|
enum WoodType{
|
||||||
use EnumTrait {
|
use LegacyEnumShimTrait;
|
||||||
__construct as private Enum___construct;
|
|
||||||
|
case OAK;
|
||||||
|
case SPRUCE;
|
||||||
|
case BIRCH;
|
||||||
|
case JUNGLE;
|
||||||
|
case ACACIA;
|
||||||
|
case DARK_OAK;
|
||||||
|
case MANGROVE;
|
||||||
|
case CRIMSON;
|
||||||
|
case WARPED;
|
||||||
|
case CHERRY;
|
||||||
|
|
||||||
|
public function getDisplayName() : string{
|
||||||
|
return match($this){
|
||||||
|
self::OAK => "Oak",
|
||||||
|
self::SPRUCE => "Spruce",
|
||||||
|
self::BIRCH => "Birch",
|
||||||
|
self::JUNGLE => "Jungle",
|
||||||
|
self::ACACIA => "Acacia",
|
||||||
|
self::DARK_OAK => "Dark Oak",
|
||||||
|
self::MANGROVE => "Mangrove",
|
||||||
|
self::CRIMSON => "Crimson",
|
||||||
|
self::WARPED => "Warped",
|
||||||
|
self::CHERRY => "Cherry",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function setup() : void{
|
public function isFlammable() : bool{
|
||||||
self::registerAll(
|
return $this !== self::CRIMSON && $this !== self::WARPED;
|
||||||
new self("oak", "Oak", true),
|
|
||||||
new self("spruce", "Spruce", true),
|
|
||||||
new self("birch", "Birch", true),
|
|
||||||
new self("jungle", "Jungle", true),
|
|
||||||
new self("acacia", "Acacia", true),
|
|
||||||
new self("dark_oak", "Dark Oak", true),
|
|
||||||
new self("mangrove", "Mangrove", true),
|
|
||||||
new self("crimson", "Crimson", false, "Stem", "Hyphae"),
|
|
||||||
new self("warped", "Warped", false, "Stem", "Hyphae"),
|
|
||||||
new self("cherry", "Cherry", true),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function __construct(
|
public function getStandardLogSuffix() : ?string{
|
||||||
string $enumName,
|
return $this === self::CRIMSON || $this === self::WARPED ? "Stem" : null;
|
||||||
private string $displayName,
|
|
||||||
private bool $flammable,
|
|
||||||
private ?string $standardLogSuffix = null,
|
|
||||||
private ?string $allSidedLogSuffix = null,
|
|
||||||
){
|
|
||||||
$this->Enum___construct($enumName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDisplayName() : string{ return $this->displayName; }
|
public function getAllSidedLogSuffix() : ?string{
|
||||||
|
return $this === self::CRIMSON || $this === self::WARPED ? "Hyphae" : null;
|
||||||
public function isFlammable() : bool{ return $this->flammable; }
|
}
|
||||||
|
|
||||||
public function getStandardLogSuffix() : ?string{ return $this->standardLogSuffix; }
|
|
||||||
|
|
||||||
public function getAllSidedLogSuffix() : ?string{ return $this->allSidedLogSuffix; }
|
|
||||||
}
|
}
|
||||||
|
@ -211,10 +211,10 @@ final class CraftingManagerFromDataHelper{
|
|||||||
|
|
||||||
foreach(self::loadJsonArrayOfObjectsFile(Path::join($directoryPath, 'shapeless_crafting.json'), ShapelessRecipeData::class) as $recipe){
|
foreach(self::loadJsonArrayOfObjectsFile(Path::join($directoryPath, 'shapeless_crafting.json'), ShapelessRecipeData::class) as $recipe){
|
||||||
$recipeType = match($recipe->block){
|
$recipeType = match($recipe->block){
|
||||||
"crafting_table" => ShapelessRecipeType::CRAFTING(),
|
"crafting_table" => ShapelessRecipeType::CRAFTING,
|
||||||
"stonecutter" => ShapelessRecipeType::STONECUTTER(),
|
"stonecutter" => ShapelessRecipeType::STONECUTTER,
|
||||||
"smithing_table" => ShapelessRecipeType::SMITHING(),
|
"smithing_table" => ShapelessRecipeType::SMITHING,
|
||||||
"cartography_table" => ShapelessRecipeType::CARTOGRAPHY(),
|
"cartography_table" => ShapelessRecipeType::CARTOGRAPHY,
|
||||||
default => null
|
default => null
|
||||||
};
|
};
|
||||||
if($recipeType === null){
|
if($recipeType === null){
|
||||||
|
@ -23,28 +23,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\crafting;
|
namespace pocketmine\crafting;
|
||||||
|
|
||||||
use pocketmine\utils\EnumTrait;
|
use pocketmine\utils\LegacyEnumShimTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doc-block is generated automatically, do not modify it manually.
|
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
|
||||||
* This must be regenerated whenever registry members are added, removed or changed.
|
* These are retained for backwards compatibility only.
|
||||||
* @see build/generate-registry-annotations.php
|
|
||||||
* @generate-registry-docblock
|
|
||||||
*
|
*
|
||||||
* @method static ShapelessRecipeType CARTOGRAPHY()
|
* @method static ShapelessRecipeType CARTOGRAPHY()
|
||||||
* @method static ShapelessRecipeType CRAFTING()
|
* @method static ShapelessRecipeType CRAFTING()
|
||||||
* @method static ShapelessRecipeType SMITHING()
|
* @method static ShapelessRecipeType SMITHING()
|
||||||
* @method static ShapelessRecipeType STONECUTTER()
|
* @method static ShapelessRecipeType STONECUTTER()
|
||||||
*/
|
*/
|
||||||
final class ShapelessRecipeType{
|
enum ShapelessRecipeType{
|
||||||
use EnumTrait;
|
use LegacyEnumShimTrait;
|
||||||
|
|
||||||
protected static function setup() : void{
|
case CRAFTING;
|
||||||
self::registerAll(
|
case STONECUTTER;
|
||||||
new self("crafting"),
|
case SMITHING;
|
||||||
new self("stonecutter"),
|
case CARTOGRAPHY;
|
||||||
new self("smithing"),
|
|
||||||
new self("cartography")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ namespace pocketmine\data\bedrock;
|
|||||||
use pocketmine\block\utils\BannerPatternType;
|
use pocketmine\block\utils\BannerPatternType;
|
||||||
use pocketmine\utils\SingletonTrait;
|
use pocketmine\utils\SingletonTrait;
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
|
use function spl_object_id;
|
||||||
|
|
||||||
final class BannerPatternTypeIdMap{
|
final class BannerPatternTypeIdMap{
|
||||||
use SingletonTrait;
|
use SingletonTrait;
|
||||||
@ -42,49 +43,49 @@ final class BannerPatternTypeIdMap{
|
|||||||
private array $enumToId = [];
|
private array $enumToId = [];
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->register("bo", BannerPatternType::BORDER());
|
$this->register("bo", BannerPatternType::BORDER);
|
||||||
$this->register("bri", BannerPatternType::BRICKS());
|
$this->register("bri", BannerPatternType::BRICKS);
|
||||||
$this->register("mc", BannerPatternType::CIRCLE());
|
$this->register("mc", BannerPatternType::CIRCLE);
|
||||||
$this->register("cre", BannerPatternType::CREEPER());
|
$this->register("cre", BannerPatternType::CREEPER);
|
||||||
$this->register("cr", BannerPatternType::CROSS());
|
$this->register("cr", BannerPatternType::CROSS);
|
||||||
$this->register("cbo", BannerPatternType::CURLY_BORDER());
|
$this->register("cbo", BannerPatternType::CURLY_BORDER);
|
||||||
$this->register("lud", BannerPatternType::DIAGONAL_LEFT());
|
$this->register("lud", BannerPatternType::DIAGONAL_LEFT);
|
||||||
$this->register("rd", BannerPatternType::DIAGONAL_RIGHT());
|
$this->register("rd", BannerPatternType::DIAGONAL_RIGHT);
|
||||||
$this->register("ld", BannerPatternType::DIAGONAL_UP_LEFT());
|
$this->register("ld", BannerPatternType::DIAGONAL_UP_LEFT);
|
||||||
$this->register("rud", BannerPatternType::DIAGONAL_UP_RIGHT());
|
$this->register("rud", BannerPatternType::DIAGONAL_UP_RIGHT);
|
||||||
$this->register("flo", BannerPatternType::FLOWER());
|
$this->register("flo", BannerPatternType::FLOWER);
|
||||||
$this->register("gra", BannerPatternType::GRADIENT());
|
$this->register("gra", BannerPatternType::GRADIENT);
|
||||||
$this->register("gru", BannerPatternType::GRADIENT_UP());
|
$this->register("gru", BannerPatternType::GRADIENT_UP);
|
||||||
$this->register("hh", BannerPatternType::HALF_HORIZONTAL());
|
$this->register("hh", BannerPatternType::HALF_HORIZONTAL);
|
||||||
$this->register("hhb", BannerPatternType::HALF_HORIZONTAL_BOTTOM());
|
$this->register("hhb", BannerPatternType::HALF_HORIZONTAL_BOTTOM);
|
||||||
$this->register("vh", BannerPatternType::HALF_VERTICAL());
|
$this->register("vh", BannerPatternType::HALF_VERTICAL);
|
||||||
$this->register("vhr", BannerPatternType::HALF_VERTICAL_RIGHT());
|
$this->register("vhr", BannerPatternType::HALF_VERTICAL_RIGHT);
|
||||||
$this->register("moj", BannerPatternType::MOJANG());
|
$this->register("moj", BannerPatternType::MOJANG);
|
||||||
$this->register("mr", BannerPatternType::RHOMBUS());
|
$this->register("mr", BannerPatternType::RHOMBUS);
|
||||||
$this->register("sku", BannerPatternType::SKULL());
|
$this->register("sku", BannerPatternType::SKULL);
|
||||||
$this->register("ss", BannerPatternType::SMALL_STRIPES());
|
$this->register("ss", BannerPatternType::SMALL_STRIPES);
|
||||||
$this->register("bl", BannerPatternType::SQUARE_BOTTOM_LEFT());
|
$this->register("bl", BannerPatternType::SQUARE_BOTTOM_LEFT);
|
||||||
$this->register("br", BannerPatternType::SQUARE_BOTTOM_RIGHT());
|
$this->register("br", BannerPatternType::SQUARE_BOTTOM_RIGHT);
|
||||||
$this->register("tl", BannerPatternType::SQUARE_TOP_LEFT());
|
$this->register("tl", BannerPatternType::SQUARE_TOP_LEFT);
|
||||||
$this->register("tr", BannerPatternType::SQUARE_TOP_RIGHT());
|
$this->register("tr", BannerPatternType::SQUARE_TOP_RIGHT);
|
||||||
$this->register("sc", BannerPatternType::STRAIGHT_CROSS());
|
$this->register("sc", BannerPatternType::STRAIGHT_CROSS);
|
||||||
$this->register("bs", BannerPatternType::STRIPE_BOTTOM());
|
$this->register("bs", BannerPatternType::STRIPE_BOTTOM);
|
||||||
$this->register("cs", BannerPatternType::STRIPE_CENTER());
|
$this->register("cs", BannerPatternType::STRIPE_CENTER);
|
||||||
$this->register("dls", BannerPatternType::STRIPE_DOWNLEFT());
|
$this->register("dls", BannerPatternType::STRIPE_DOWNLEFT);
|
||||||
$this->register("drs", BannerPatternType::STRIPE_DOWNRIGHT());
|
$this->register("drs", BannerPatternType::STRIPE_DOWNRIGHT);
|
||||||
$this->register("ls", BannerPatternType::STRIPE_LEFT());
|
$this->register("ls", BannerPatternType::STRIPE_LEFT);
|
||||||
$this->register("ms", BannerPatternType::STRIPE_MIDDLE());
|
$this->register("ms", BannerPatternType::STRIPE_MIDDLE);
|
||||||
$this->register("rs", BannerPatternType::STRIPE_RIGHT());
|
$this->register("rs", BannerPatternType::STRIPE_RIGHT);
|
||||||
$this->register("ts", BannerPatternType::STRIPE_TOP());
|
$this->register("ts", BannerPatternType::STRIPE_TOP);
|
||||||
$this->register("bt", BannerPatternType::TRIANGLE_BOTTOM());
|
$this->register("bt", BannerPatternType::TRIANGLE_BOTTOM);
|
||||||
$this->register("tt", BannerPatternType::TRIANGLE_TOP());
|
$this->register("tt", BannerPatternType::TRIANGLE_TOP);
|
||||||
$this->register("bts", BannerPatternType::TRIANGLES_BOTTOM());
|
$this->register("bts", BannerPatternType::TRIANGLES_BOTTOM);
|
||||||
$this->register("tts", BannerPatternType::TRIANGLES_TOP());
|
$this->register("tts", BannerPatternType::TRIANGLES_TOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(string $stringId, BannerPatternType $type) : void{
|
public function register(string $stringId, BannerPatternType $type) : void{
|
||||||
$this->idToEnum[$stringId] = $type;
|
$this->idToEnum[$stringId] = $type;
|
||||||
$this->enumToId[$type->id()] = $stringId;
|
$this->enumToId[spl_object_id($type)] = $stringId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fromId(string $id) : ?BannerPatternType{
|
public function fromId(string $id) : ?BannerPatternType{
|
||||||
@ -92,9 +93,10 @@ final class BannerPatternTypeIdMap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function toId(BannerPatternType $type) : string{
|
public function toId(BannerPatternType $type) : string{
|
||||||
if(!array_key_exists($type->id(), $this->enumToId)){
|
$k = spl_object_id($type);
|
||||||
throw new \InvalidArgumentException("Missing mapping for banner pattern type " . $type->name());
|
if(!array_key_exists($k, $this->enumToId)){
|
||||||
|
throw new \InvalidArgumentException("Missing mapping for banner pattern type " . $type->name);
|
||||||
}
|
}
|
||||||
return $this->enumToId[$type->id()];
|
return $this->enumToId[$k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@ final class MobHeadTypeIdMap{
|
|||||||
use IntSaveIdMapTrait;
|
use IntSaveIdMapTrait;
|
||||||
|
|
||||||
private function __construct(){
|
private function __construct(){
|
||||||
$this->register(0, MobHeadType::SKELETON());
|
$this->register(0, MobHeadType::SKELETON);
|
||||||
$this->register(1, MobHeadType::WITHER_SKELETON());
|
$this->register(1, MobHeadType::WITHER_SKELETON);
|
||||||
$this->register(2, MobHeadType::ZOMBIE());
|
$this->register(2, MobHeadType::ZOMBIE);
|
||||||
$this->register(3, MobHeadType::PLAYER());
|
$this->register(3, MobHeadType::PLAYER);
|
||||||
$this->register(4, MobHeadType::CREEPER());
|
$this->register(4, MobHeadType::CREEPER);
|
||||||
$this->register(5, MobHeadType::DRAGON());
|
$this->register(5, MobHeadType::DRAGON);
|
||||||
$this->register(6, MobHeadType::PIGLIN());
|
$this->register(6, MobHeadType::PIGLIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,16 @@ final class MushroomBlockTypeIdMap{
|
|||||||
use IntSaveIdMapTrait;
|
use IntSaveIdMapTrait;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_ALL_PORES, MushroomBlockType::PORES());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_ALL_PORES, MushroomBlockType::PORES);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_NORTHWEST_CORNER, MushroomBlockType::CAP_NORTHWEST());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_NORTHWEST_CORNER, MushroomBlockType::CAP_NORTHWEST);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_NORTH_SIDE, MushroomBlockType::CAP_NORTH());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_NORTH_SIDE, MushroomBlockType::CAP_NORTH);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_NORTHEAST_CORNER, MushroomBlockType::CAP_NORTHEAST());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_NORTHEAST_CORNER, MushroomBlockType::CAP_NORTHEAST);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_WEST_SIDE, MushroomBlockType::CAP_WEST());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_WEST_SIDE, MushroomBlockType::CAP_WEST);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_TOP_ONLY, MushroomBlockType::CAP_MIDDLE());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_TOP_ONLY, MushroomBlockType::CAP_MIDDLE);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_EAST_SIDE, MushroomBlockType::CAP_EAST());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_EAST_SIDE, MushroomBlockType::CAP_EAST);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_SOUTHWEST_CORNER, MushroomBlockType::CAP_SOUTHWEST());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_SOUTHWEST_CORNER, MushroomBlockType::CAP_SOUTHWEST);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_SOUTH_SIDE, MushroomBlockType::CAP_SOUTH());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_SOUTH_SIDE, MushroomBlockType::CAP_SOUTH);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_SOUTHEAST_CORNER, MushroomBlockType::CAP_SOUTHEAST());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_CAP_SOUTHEAST_CORNER, MushroomBlockType::CAP_SOUTHEAST);
|
||||||
$this->register(LegacyMeta::MUSHROOM_BLOCK_ALL_CAP, MushroomBlockType::ALL_CAP());
|
$this->register(LegacyMeta::MUSHROOM_BLOCK_ALL_CAP, MushroomBlockType::ALL_CAP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,21 +32,21 @@ final class NoteInstrumentIdMap{
|
|||||||
use IntSaveIdMapTrait;
|
use IntSaveIdMapTrait;
|
||||||
|
|
||||||
private function __construct(){
|
private function __construct(){
|
||||||
$this->register(0, NoteInstrument::PIANO());
|
$this->register(0, NoteInstrument::PIANO);
|
||||||
$this->register(1, NoteInstrument::BASS_DRUM());
|
$this->register(1, NoteInstrument::BASS_DRUM);
|
||||||
$this->register(2, NoteInstrument::SNARE());
|
$this->register(2, NoteInstrument::SNARE);
|
||||||
$this->register(3, NoteInstrument::CLICKS_AND_STICKS());
|
$this->register(3, NoteInstrument::CLICKS_AND_STICKS);
|
||||||
$this->register(4, NoteInstrument::DOUBLE_BASS());
|
$this->register(4, NoteInstrument::DOUBLE_BASS);
|
||||||
$this->register(5, NoteInstrument::BELL());
|
$this->register(5, NoteInstrument::BELL);
|
||||||
$this->register(6, NoteInstrument::FLUTE());
|
$this->register(6, NoteInstrument::FLUTE);
|
||||||
$this->register(7, NoteInstrument::CHIME());
|
$this->register(7, NoteInstrument::CHIME);
|
||||||
$this->register(8, NoteInstrument::GUITAR());
|
$this->register(8, NoteInstrument::GUITAR);
|
||||||
$this->register(9, NoteInstrument::XYLOPHONE());
|
$this->register(9, NoteInstrument::XYLOPHONE);
|
||||||
$this->register(10, NoteInstrument::IRON_XYLOPHONE());
|
$this->register(10, NoteInstrument::IRON_XYLOPHONE);
|
||||||
$this->register(11, NoteInstrument::COW_BELL());
|
$this->register(11, NoteInstrument::COW_BELL);
|
||||||
$this->register(12, NoteInstrument::DIDGERIDOO());
|
$this->register(12, NoteInstrument::DIDGERIDOO);
|
||||||
$this->register(13, NoteInstrument::BIT());
|
$this->register(13, NoteInstrument::BIT);
|
||||||
$this->register(14, NoteInstrument::BANJO());
|
$this->register(14, NoteInstrument::BANJO);
|
||||||
$this->register(15, NoteInstrument::PLING());
|
$this->register(15, NoteInstrument::PLING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,13 +419,12 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
|
|
||||||
private function registerFlatCoralSerializers() : void{
|
private function registerFlatCoralSerializers() : void{
|
||||||
$this->map(Blocks::CORAL(), fn(Coral $block) => Writer::create(
|
$this->map(Blocks::CORAL(), fn(Coral $block) => Writer::create(
|
||||||
match($coralType = $block->getCoralType()){
|
match($block->getCoralType()){
|
||||||
CoralType::BRAIN() => $block->isDead() ? Ids::DEAD_BRAIN_CORAL : Ids::BRAIN_CORAL,
|
CoralType::BRAIN => $block->isDead() ? Ids::DEAD_BRAIN_CORAL : Ids::BRAIN_CORAL,
|
||||||
CoralType::BUBBLE() => $block->isDead() ? Ids::DEAD_BUBBLE_CORAL : Ids::BUBBLE_CORAL,
|
CoralType::BUBBLE => $block->isDead() ? Ids::DEAD_BUBBLE_CORAL : Ids::BUBBLE_CORAL,
|
||||||
CoralType::FIRE() => $block->isDead() ? Ids::DEAD_FIRE_CORAL : Ids::FIRE_CORAL,
|
CoralType::FIRE => $block->isDead() ? Ids::DEAD_FIRE_CORAL : Ids::FIRE_CORAL,
|
||||||
CoralType::HORN() => $block->isDead() ? Ids::DEAD_HORN_CORAL : Ids::HORN_CORAL,
|
CoralType::HORN => $block->isDead() ? Ids::DEAD_HORN_CORAL : Ids::HORN_CORAL,
|
||||||
CoralType::TUBE() => $block->isDead() ? Ids::DEAD_TUBE_CORAL : Ids::TUBE_CORAL,
|
CoralType::TUBE => $block->isDead() ? Ids::DEAD_TUBE_CORAL : Ids::TUBE_CORAL,
|
||||||
default => throw new AssumptionFailedError("Unhandled coral type " . $coralType->name())
|
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -966,12 +965,11 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
$this->map(Blocks::BIG_DRIPLEAF_HEAD(), function(BigDripleafHead $block) : Writer{
|
$this->map(Blocks::BIG_DRIPLEAF_HEAD(), function(BigDripleafHead $block) : Writer{
|
||||||
return Writer::create(Ids::BIG_DRIPLEAF)
|
return Writer::create(Ids::BIG_DRIPLEAF)
|
||||||
->writeLegacyHorizontalFacing($block->getFacing())
|
->writeLegacyHorizontalFacing($block->getFacing())
|
||||||
->writeString(StateNames::BIG_DRIPLEAF_TILT, match($block->getLeafState()->id()){
|
->writeString(StateNames::BIG_DRIPLEAF_TILT, match($block->getLeafState()){
|
||||||
DripleafState::STABLE()->id() => StringValues::BIG_DRIPLEAF_TILT_NONE,
|
DripleafState::STABLE => StringValues::BIG_DRIPLEAF_TILT_NONE,
|
||||||
DripleafState::UNSTABLE()->id() => StringValues::BIG_DRIPLEAF_TILT_UNSTABLE,
|
DripleafState::UNSTABLE => StringValues::BIG_DRIPLEAF_TILT_UNSTABLE,
|
||||||
DripleafState::PARTIAL_TILT()->id() => StringValues::BIG_DRIPLEAF_TILT_PARTIAL_TILT,
|
DripleafState::PARTIAL_TILT => StringValues::BIG_DRIPLEAF_TILT_PARTIAL_TILT,
|
||||||
DripleafState::FULL_TILT()->id() => StringValues::BIG_DRIPLEAF_TILT_FULL_TILT,
|
DripleafState::FULL_TILT => StringValues::BIG_DRIPLEAF_TILT_FULL_TILT,
|
||||||
default => throw new BlockStateSerializeException("Invalid Dripleaf tilt type " . $block->getLeafState()->name())
|
|
||||||
})
|
})
|
||||||
->writeBool(StateNames::BIG_DRIPLEAF_HEAD, true);
|
->writeBool(StateNames::BIG_DRIPLEAF_HEAD, true);
|
||||||
});
|
});
|
||||||
@ -995,9 +993,9 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
});
|
});
|
||||||
$this->map(Blocks::BREWING_STAND(), function(BrewingStand $block) : Writer{
|
$this->map(Blocks::BREWING_STAND(), function(BrewingStand $block) : Writer{
|
||||||
return Writer::create(Ids::BREWING_STAND)
|
return Writer::create(Ids::BREWING_STAND)
|
||||||
->writeBool(StateNames::BREWING_STAND_SLOT_A_BIT, $block->hasSlot(BrewingStandSlot::EAST()))
|
->writeBool(StateNames::BREWING_STAND_SLOT_A_BIT, $block->hasSlot(BrewingStandSlot::EAST))
|
||||||
->writeBool(StateNames::BREWING_STAND_SLOT_B_BIT, $block->hasSlot(BrewingStandSlot::SOUTHWEST()))
|
->writeBool(StateNames::BREWING_STAND_SLOT_B_BIT, $block->hasSlot(BrewingStandSlot::SOUTHWEST))
|
||||||
->writeBool(StateNames::BREWING_STAND_SLOT_C_BIT, $block->hasSlot(BrewingStandSlot::NORTHWEST()));
|
->writeBool(StateNames::BREWING_STAND_SLOT_C_BIT, $block->hasSlot(BrewingStandSlot::NORTHWEST));
|
||||||
});
|
});
|
||||||
$this->map(Blocks::BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_BRICK));
|
$this->map(Blocks::BRICK_SLAB(), fn(Slab $block) => Helper::encodeStoneSlab1($block, StringValues::STONE_SLAB_TYPE_BRICK));
|
||||||
$this->mapStairs(Blocks::BRICK_STAIRS(), Ids::BRICK_STAIRS);
|
$this->mapStairs(Blocks::BRICK_STAIRS(), Ids::BRICK_STAIRS);
|
||||||
@ -1184,14 +1182,14 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
$this->map(Blocks::DIORITE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_DIORITE));
|
$this->map(Blocks::DIORITE_WALL(), fn(Wall $block) => Helper::encodeLegacyWall($block, StringValues::WALL_BLOCK_TYPE_DIORITE));
|
||||||
$this->map(Blocks::DIRT(), function(Dirt $block) : Writer{
|
$this->map(Blocks::DIRT(), function(Dirt $block) : Writer{
|
||||||
$dirtType = $block->getDirtType();
|
$dirtType = $block->getDirtType();
|
||||||
if($dirtType->equals(DirtType::ROOTED())){
|
if($dirtType === DirtType::ROOTED){
|
||||||
return new Writer(Ids::DIRT_WITH_ROOTS);
|
return new Writer(Ids::DIRT_WITH_ROOTS);
|
||||||
}
|
}
|
||||||
return Writer::create(Ids::DIRT)
|
return Writer::create(Ids::DIRT)
|
||||||
->writeString(StateNames::DIRT_TYPE, match($dirtType){
|
->writeString(StateNames::DIRT_TYPE, match($dirtType){
|
||||||
DirtType::COARSE() => StringValues::DIRT_TYPE_COARSE,
|
DirtType::COARSE => StringValues::DIRT_TYPE_COARSE,
|
||||||
DirtType::NORMAL() => StringValues::DIRT_TYPE_NORMAL,
|
DirtType::NORMAL => StringValues::DIRT_TYPE_NORMAL,
|
||||||
default => throw new AssumptionFailedError("Unhandled dirt type " . $dirtType->name())
|
//ROOTED was already checked above
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$this->map(Blocks::DOUBLE_TALLGRASS(), fn(DoubleTallGrass $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_GRASS, Writer::create(Ids::DOUBLE_PLANT)));
|
$this->map(Blocks::DOUBLE_TALLGRASS(), fn(DoubleTallGrass $block) => Helper::encodeDoublePlant($block, StringValues::DOUBLE_PLANT_TYPE_GRASS, Writer::create(Ids::DOUBLE_PLANT)));
|
||||||
@ -1229,10 +1227,9 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
});
|
});
|
||||||
$this->map(Blocks::FROGLIGHT(), function(Froglight $block){
|
$this->map(Blocks::FROGLIGHT(), function(Froglight $block){
|
||||||
return Writer::create(match($block->getFroglightType()){
|
return Writer::create(match($block->getFroglightType()){
|
||||||
FroglightType::OCHRE() => Ids::OCHRE_FROGLIGHT,
|
FroglightType::OCHRE => Ids::OCHRE_FROGLIGHT,
|
||||||
FroglightType::PEARLESCENT() => Ids::PEARLESCENT_FROGLIGHT,
|
FroglightType::PEARLESCENT => Ids::PEARLESCENT_FROGLIGHT,
|
||||||
FroglightType::VERDANT() => Ids::VERDANT_FROGLIGHT,
|
FroglightType::VERDANT => Ids::VERDANT_FROGLIGHT,
|
||||||
default => throw new AssumptionFailedError("Unhandled froglight type " . $block->getFroglightType()->name())
|
|
||||||
})
|
})
|
||||||
->writePillarAxis($block->getAxis());
|
->writePillarAxis($block->getAxis());
|
||||||
});
|
});
|
||||||
@ -1296,16 +1293,15 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
$this->map(Blocks::LEVER(), function(Lever $block) : Writer{
|
$this->map(Blocks::LEVER(), function(Lever $block) : Writer{
|
||||||
return Writer::create(Ids::LEVER)
|
return Writer::create(Ids::LEVER)
|
||||||
->writeBool(StateNames::OPEN_BIT, $block->isActivated())
|
->writeBool(StateNames::OPEN_BIT, $block->isActivated())
|
||||||
->writeString(StateNames::LEVER_DIRECTION, match($block->getFacing()->id()){
|
->writeString(StateNames::LEVER_DIRECTION, match($block->getFacing()){
|
||||||
LeverFacing::DOWN_AXIS_Z()->id() => StringValues::LEVER_DIRECTION_DOWN_NORTH_SOUTH,
|
LeverFacing::DOWN_AXIS_Z => StringValues::LEVER_DIRECTION_DOWN_NORTH_SOUTH,
|
||||||
LeverFacing::DOWN_AXIS_X()->id() => StringValues::LEVER_DIRECTION_DOWN_EAST_WEST,
|
LeverFacing::DOWN_AXIS_X => StringValues::LEVER_DIRECTION_DOWN_EAST_WEST,
|
||||||
LeverFacing::UP_AXIS_Z()->id() => StringValues::LEVER_DIRECTION_UP_NORTH_SOUTH,
|
LeverFacing::UP_AXIS_Z => StringValues::LEVER_DIRECTION_UP_NORTH_SOUTH,
|
||||||
LeverFacing::UP_AXIS_X()->id() => StringValues::LEVER_DIRECTION_UP_EAST_WEST,
|
LeverFacing::UP_AXIS_X => StringValues::LEVER_DIRECTION_UP_EAST_WEST,
|
||||||
LeverFacing::NORTH()->id() => StringValues::LEVER_DIRECTION_NORTH,
|
LeverFacing::NORTH => StringValues::LEVER_DIRECTION_NORTH,
|
||||||
LeverFacing::SOUTH()->id() => StringValues::LEVER_DIRECTION_SOUTH,
|
LeverFacing::SOUTH => StringValues::LEVER_DIRECTION_SOUTH,
|
||||||
LeverFacing::WEST()->id() => StringValues::LEVER_DIRECTION_WEST,
|
LeverFacing::WEST => StringValues::LEVER_DIRECTION_WEST,
|
||||||
LeverFacing::EAST()->id() => StringValues::LEVER_DIRECTION_EAST,
|
LeverFacing::EAST => StringValues::LEVER_DIRECTION_EAST,
|
||||||
default => throw new BlockStateSerializeException("Invalid Lever facing " . $block->getFacing()->name()),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$this->map(Blocks::LIGHT(), function(Light $block) : Writer{
|
$this->map(Blocks::LIGHT(), function(Light $block) : Writer{
|
||||||
@ -1606,13 +1602,12 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
|||||||
});
|
});
|
||||||
$this->map(Blocks::WALL_CORAL_FAN(), function(WallCoralFan $block) : Writer{
|
$this->map(Blocks::WALL_CORAL_FAN(), function(WallCoralFan $block) : Writer{
|
||||||
$coralType = $block->getCoralType();
|
$coralType = $block->getCoralType();
|
||||||
return Writer::create(match($coralType->id()){
|
return Writer::create(match($coralType){
|
||||||
CoralType::TUBE()->id(), CoralType::BRAIN()->id() => Ids::CORAL_FAN_HANG,
|
CoralType::TUBE, CoralType::BRAIN => Ids::CORAL_FAN_HANG,
|
||||||
CoralType::BUBBLE()->id(), CoralType::FIRE()->id() => Ids::CORAL_FAN_HANG2,
|
CoralType::BUBBLE, CoralType::FIRE => Ids::CORAL_FAN_HANG2,
|
||||||
CoralType::HORN()->id() => Ids::CORAL_FAN_HANG3,
|
CoralType::HORN => Ids::CORAL_FAN_HANG3,
|
||||||
default => throw new BlockStateSerializeException("Invalid Coral type " . $coralType->name()),
|
|
||||||
})
|
})
|
||||||
->writeBool(StateNames::CORAL_HANG_TYPE_BIT, $coralType->equals(CoralType::BRAIN()) || $coralType->equals(CoralType::FIRE()))
|
->writeBool(StateNames::CORAL_HANG_TYPE_BIT, $coralType === CoralType::BRAIN || $coralType === CoralType::FIRE)
|
||||||
->writeBool(StateNames::DEAD_BIT, $block->isDead())
|
->writeBool(StateNames::DEAD_BIT, $block->isDead())
|
||||||
->writeCoralFacing($block->getFacing());
|
->writeCoralFacing($block->getFacing());
|
||||||
});
|
});
|
||||||
|
@ -293,7 +293,7 @@ final class BlockStateReader{
|
|||||||
|
|
||||||
/** @throws BlockStateDeserializeException */
|
/** @throws BlockStateDeserializeException */
|
||||||
public function readSlabPosition() : SlabType{
|
public function readSlabPosition() : SlabType{
|
||||||
return $this->readBool(BlockStateNames::TOP_SLOT_BIT) ? SlabType::TOP() : SlabType::BOTTOM();
|
return $this->readBool(BlockStateNames::TOP_SLOT_BIT) ? SlabType::TOP : SlabType::BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -316,11 +316,11 @@ final class BlockStateReader{
|
|||||||
/** @throws BlockStateDeserializeException */
|
/** @throws BlockStateDeserializeException */
|
||||||
public function readCoralType() : CoralType{
|
public function readCoralType() : CoralType{
|
||||||
return match($type = $this->readString(BlockStateNames::CORAL_COLOR)){
|
return match($type = $this->readString(BlockStateNames::CORAL_COLOR)){
|
||||||
StringValues::CORAL_COLOR_BLUE => CoralType::TUBE(),
|
StringValues::CORAL_COLOR_BLUE => CoralType::TUBE,
|
||||||
StringValues::CORAL_COLOR_PINK => CoralType::BRAIN(),
|
StringValues::CORAL_COLOR_PINK => CoralType::BRAIN,
|
||||||
StringValues::CORAL_COLOR_PURPLE => CoralType::BUBBLE(),
|
StringValues::CORAL_COLOR_PURPLE => CoralType::BUBBLE,
|
||||||
StringValues::CORAL_COLOR_RED => CoralType::FIRE(),
|
StringValues::CORAL_COLOR_RED => CoralType::FIRE,
|
||||||
StringValues::CORAL_COLOR_YELLOW => CoralType::HORN(),
|
StringValues::CORAL_COLOR_YELLOW => CoralType::HORN,
|
||||||
default => throw $this->badValueException(BlockStateNames::CORAL_COLOR, $type),
|
default => throw $this->badValueException(BlockStateNames::CORAL_COLOR, $type),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -328,10 +328,10 @@ final class BlockStateReader{
|
|||||||
/** @throws BlockStateDeserializeException */
|
/** @throws BlockStateDeserializeException */
|
||||||
public function readBellAttachmentType() : BellAttachmentType{
|
public function readBellAttachmentType() : BellAttachmentType{
|
||||||
return match($type = $this->readString(BlockStateNames::ATTACHMENT)){
|
return match($type = $this->readString(BlockStateNames::ATTACHMENT)){
|
||||||
StringValues::ATTACHMENT_HANGING => BellAttachmentType::CEILING(),
|
StringValues::ATTACHMENT_HANGING => BellAttachmentType::CEILING,
|
||||||
StringValues::ATTACHMENT_STANDING => BellAttachmentType::FLOOR(),
|
StringValues::ATTACHMENT_STANDING => BellAttachmentType::FLOOR,
|
||||||
StringValues::ATTACHMENT_SIDE => BellAttachmentType::ONE_WALL(),
|
StringValues::ATTACHMENT_SIDE => BellAttachmentType::ONE_WALL,
|
||||||
StringValues::ATTACHMENT_MULTIPLE => BellAttachmentType::TWO_WALLS(),
|
StringValues::ATTACHMENT_MULTIPLE => BellAttachmentType::TWO_WALLS,
|
||||||
default => throw $this->badValueException(BlockStateNames::ATTACHMENT, $type),
|
default => throw $this->badValueException(BlockStateNames::ATTACHMENT, $type),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -343,8 +343,8 @@ final class BlockStateReader{
|
|||||||
//we need to find a better way to auto-generate the constant names when they are reused
|
//we need to find a better way to auto-generate the constant names when they are reused
|
||||||
//for now, using these constants is better than nothing since it still gives static analysability
|
//for now, using these constants is better than nothing since it still gives static analysability
|
||||||
StringValues::WALL_CONNECTION_TYPE_EAST_NONE => null,
|
StringValues::WALL_CONNECTION_TYPE_EAST_NONE => null,
|
||||||
StringValues::WALL_CONNECTION_TYPE_EAST_SHORT => WallConnectionType::SHORT(),
|
StringValues::WALL_CONNECTION_TYPE_EAST_SHORT => WallConnectionType::SHORT,
|
||||||
StringValues::WALL_CONNECTION_TYPE_EAST_TALL => WallConnectionType::TALL(),
|
StringValues::WALL_CONNECTION_TYPE_EAST_TALL => WallConnectionType::TALL,
|
||||||
default => throw $this->badValueException($name, $type),
|
default => throw $this->badValueException($name, $type),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ use pocketmine\data\bedrock\block\BlockTypeNames as Ids;
|
|||||||
use pocketmine\data\bedrock\block\convert\BlockStateWriter as Writer;
|
use pocketmine\data\bedrock\block\convert\BlockStateWriter as Writer;
|
||||||
use pocketmine\data\bedrock\MushroomBlockTypeIdMap;
|
use pocketmine\data\bedrock\MushroomBlockTypeIdMap;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use pocketmine\utils\AssumptionFailedError;
|
|
||||||
|
|
||||||
final class BlockStateSerializerHelper{
|
final class BlockStateSerializerHelper{
|
||||||
|
|
||||||
@ -101,11 +100,10 @@ final class BlockStateSerializerHelper{
|
|||||||
|
|
||||||
public static function selectCopperId(CopperOxidation $oxidation, string $noneId, string $exposedId, string $weatheredId, string $oxidizedId) : string{
|
public static function selectCopperId(CopperOxidation $oxidation, string $noneId, string $exposedId, string $weatheredId, string $oxidizedId) : string{
|
||||||
return match($oxidation){
|
return match($oxidation){
|
||||||
CopperOxidation::NONE() => $noneId,
|
CopperOxidation::NONE => $noneId,
|
||||||
CopperOxidation::EXPOSED() => $exposedId,
|
CopperOxidation::EXPOSED => $exposedId,
|
||||||
CopperOxidation::WEATHERED() => $weatheredId,
|
CopperOxidation::WEATHERED => $weatheredId,
|
||||||
CopperOxidation::OXIDIZED() => $oxidizedId,
|
CopperOxidation::OXIDIZED => $oxidizedId,
|
||||||
default => throw new AssumptionFailedError("Unhandled copper oxidation " . $oxidation->name())
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,10 +208,10 @@ final class BlockStateSerializerHelper{
|
|||||||
|
|
||||||
public static function encodeSlab(Slab $block, string $singleId, string $doubleId) : BlockStateWriter{
|
public static function encodeSlab(Slab $block, string $singleId, string $doubleId) : BlockStateWriter{
|
||||||
$slabType = $block->getSlabType();
|
$slabType = $block->getSlabType();
|
||||||
return BlockStateWriter::create($slabType->equals(SlabType::DOUBLE()) ? $doubleId : $singleId)
|
return BlockStateWriter::create($slabType === SlabType::DOUBLE ? $doubleId : $singleId)
|
||||||
|
|
||||||
//this is (intentionally) also written for double slabs (as zero) to maintain bug parity with MCPE
|
//this is (intentionally) also written for double slabs (as zero) to maintain bug parity with MCPE
|
||||||
->writeBool(BlockStateNames::TOP_SLOT_BIT, $slabType->equals(SlabType::TOP()));
|
->writeBool(BlockStateNames::TOP_SLOT_BIT, $slabType === SlabType::TOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function encodeStairs(Stair $block, BlockStateWriter $out) : BlockStateWriter{
|
public static function encodeStairs(Stair $block, BlockStateWriter $out) : BlockStateWriter{
|
||||||
|
@ -114,7 +114,7 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
$this->map($singleId, fn(Reader $in) : Slab => $getBlock($in)->setSlabType($in->readSlabPosition()));
|
$this->map($singleId, fn(Reader $in) : Slab => $getBlock($in)->setSlabType($in->readSlabPosition()));
|
||||||
$this->map($doubleId, function(Reader $in) use ($getBlock) : Slab{
|
$this->map($doubleId, function(Reader $in) use ($getBlock) : Slab{
|
||||||
$in->ignored(StateNames::TOP_SLOT_BIT);
|
$in->ignored(StateNames::TOP_SLOT_BIT);
|
||||||
return $getBlock($in)->setSlabType(SlabType::DOUBLE());
|
return $getBlock($in)->setSlabType(SlabType::DOUBLE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,20 +292,20 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
|
|
||||||
private function registerFlatCoralDeserializers() : void{
|
private function registerFlatCoralDeserializers() : void{
|
||||||
foreach([
|
foreach([
|
||||||
Ids::BRAIN_CORAL => CoralType::BRAIN(),
|
Ids::BRAIN_CORAL => CoralType::BRAIN,
|
||||||
Ids::BUBBLE_CORAL => CoralType::BUBBLE(),
|
Ids::BUBBLE_CORAL => CoralType::BUBBLE,
|
||||||
Ids::FIRE_CORAL => CoralType::FIRE(),
|
Ids::FIRE_CORAL => CoralType::FIRE,
|
||||||
Ids::HORN_CORAL => CoralType::HORN(),
|
Ids::HORN_CORAL => CoralType::HORN,
|
||||||
Ids::TUBE_CORAL => CoralType::TUBE(),
|
Ids::TUBE_CORAL => CoralType::TUBE,
|
||||||
] as $id => $coralType){
|
] as $id => $coralType){
|
||||||
$this->mapSimple($id, fn() => Blocks::CORAL()->setCoralType($coralType)->setDead(false));
|
$this->mapSimple($id, fn() => Blocks::CORAL()->setCoralType($coralType)->setDead(false));
|
||||||
}
|
}
|
||||||
foreach([
|
foreach([
|
||||||
Ids::DEAD_BRAIN_CORAL => CoralType::BRAIN(),
|
Ids::DEAD_BRAIN_CORAL => CoralType::BRAIN,
|
||||||
Ids::DEAD_BUBBLE_CORAL => CoralType::BUBBLE(),
|
Ids::DEAD_BUBBLE_CORAL => CoralType::BUBBLE,
|
||||||
Ids::DEAD_FIRE_CORAL => CoralType::FIRE(),
|
Ids::DEAD_FIRE_CORAL => CoralType::FIRE,
|
||||||
Ids::DEAD_HORN_CORAL => CoralType::HORN(),
|
Ids::DEAD_HORN_CORAL => CoralType::HORN,
|
||||||
Ids::DEAD_TUBE_CORAL => CoralType::TUBE(),
|
Ids::DEAD_TUBE_CORAL => CoralType::TUBE,
|
||||||
] as $id => $coralType){
|
] as $id => $coralType){
|
||||||
$this->mapSimple($id, fn() => Blocks::CORAL()->setCoralType($coralType)->setDead(true));
|
$this->mapSimple($id, fn() => Blocks::CORAL()->setCoralType($coralType)->setDead(true));
|
||||||
}
|
}
|
||||||
@ -833,10 +833,10 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
return Blocks::BIG_DRIPLEAF_HEAD()
|
return Blocks::BIG_DRIPLEAF_HEAD()
|
||||||
->setFacing($in->readLegacyHorizontalFacing())
|
->setFacing($in->readLegacyHorizontalFacing())
|
||||||
->setLeafState(match($type = $in->readString(StateNames::BIG_DRIPLEAF_TILT)){
|
->setLeafState(match($type = $in->readString(StateNames::BIG_DRIPLEAF_TILT)){
|
||||||
StringValues::BIG_DRIPLEAF_TILT_NONE => DripleafState::STABLE(),
|
StringValues::BIG_DRIPLEAF_TILT_NONE => DripleafState::STABLE,
|
||||||
StringValues::BIG_DRIPLEAF_TILT_UNSTABLE => DripleafState::UNSTABLE(),
|
StringValues::BIG_DRIPLEAF_TILT_UNSTABLE => DripleafState::UNSTABLE,
|
||||||
StringValues::BIG_DRIPLEAF_TILT_PARTIAL_TILT => DripleafState::PARTIAL_TILT(),
|
StringValues::BIG_DRIPLEAF_TILT_PARTIAL_TILT => DripleafState::PARTIAL_TILT,
|
||||||
StringValues::BIG_DRIPLEAF_TILT_FULL_TILT => DripleafState::FULL_TILT(),
|
StringValues::BIG_DRIPLEAF_TILT_FULL_TILT => DripleafState::FULL_TILT,
|
||||||
default => throw $in->badValueException(StateNames::BIG_DRIPLEAF_TILT, $type),
|
default => throw $in->badValueException(StateNames::BIG_DRIPLEAF_TILT, $type),
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
@ -858,9 +858,9 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
});
|
});
|
||||||
$this->map(Ids::BREWING_STAND, function(Reader $in) : Block{
|
$this->map(Ids::BREWING_STAND, function(Reader $in) : Block{
|
||||||
return Blocks::BREWING_STAND()
|
return Blocks::BREWING_STAND()
|
||||||
->setSlot(BrewingStandSlot::EAST(), $in->readBool(StateNames::BREWING_STAND_SLOT_A_BIT))
|
->setSlot(BrewingStandSlot::EAST, $in->readBool(StateNames::BREWING_STAND_SLOT_A_BIT))
|
||||||
->setSlot(BrewingStandSlot::SOUTHWEST(), $in->readBool(StateNames::BREWING_STAND_SLOT_B_BIT))
|
->setSlot(BrewingStandSlot::SOUTHWEST, $in->readBool(StateNames::BREWING_STAND_SLOT_B_BIT))
|
||||||
->setSlot(BrewingStandSlot::NORTHWEST(), $in->readBool(StateNames::BREWING_STAND_SLOT_C_BIT));
|
->setSlot(BrewingStandSlot::NORTHWEST, $in->readBool(StateNames::BREWING_STAND_SLOT_C_BIT));
|
||||||
});
|
});
|
||||||
$this->mapStairs(Ids::BRICK_STAIRS, fn() => Blocks::BRICK_STAIRS());
|
$this->mapStairs(Ids::BRICK_STAIRS, fn() => Blocks::BRICK_STAIRS());
|
||||||
$this->map(Ids::BROWN_MUSHROOM_BLOCK, fn(Reader $in) => Helper::decodeMushroomBlock(Blocks::BROWN_MUSHROOM_BLOCK(), $in));
|
$this->map(Ids::BROWN_MUSHROOM_BLOCK, fn(Reader $in) => Helper::decodeMushroomBlock(Blocks::BROWN_MUSHROOM_BLOCK(), $in));
|
||||||
@ -939,10 +939,10 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
return Blocks::CONCRETE_POWDER()
|
return Blocks::CONCRETE_POWDER()
|
||||||
->setColor($in->readColor());
|
->setColor($in->readColor());
|
||||||
});
|
});
|
||||||
$this->map(Ids::COPPER_BLOCK, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::NONE()));
|
$this->map(Ids::COPPER_BLOCK, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::NONE));
|
||||||
$this->map(Ids::CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE()));
|
$this->map(Ids::CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE));
|
||||||
$this->mapSlab(Ids::CUT_COPPER_SLAB, Ids::DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE()));
|
$this->mapSlab(Ids::CUT_COPPER_SLAB, Ids::DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE));
|
||||||
$this->mapStairs(Ids::CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE()));
|
$this->mapStairs(Ids::CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE));
|
||||||
$this->map(Ids::CORAL_BLOCK, function(Reader $in) : Block{
|
$this->map(Ids::CORAL_BLOCK, function(Reader $in) : Block{
|
||||||
return Blocks::CORAL_BLOCK()
|
return Blocks::CORAL_BLOCK()
|
||||||
->setCoralType($in->readCoralType())
|
->setCoralType($in->readCoralType())
|
||||||
@ -953,13 +953,13 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
$this->map(Ids::CORAL_FAN_DEAD, fn(Reader $in) => Helper::decodeFloorCoralFan(Blocks::CORAL_FAN(), $in)
|
$this->map(Ids::CORAL_FAN_DEAD, fn(Reader $in) => Helper::decodeFloorCoralFan(Blocks::CORAL_FAN(), $in)
|
||||||
->setDead(true));
|
->setDead(true));
|
||||||
$this->map(Ids::CORAL_FAN_HANG, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in)
|
$this->map(Ids::CORAL_FAN_HANG, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in)
|
||||||
->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::BRAIN() : CoralType::TUBE()));
|
->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::BRAIN : CoralType::TUBE));
|
||||||
$this->map(Ids::CORAL_FAN_HANG2, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in)
|
$this->map(Ids::CORAL_FAN_HANG2, fn(Reader $in) => Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in)
|
||||||
->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::FIRE() : CoralType::BUBBLE()));
|
->setCoralType($in->readBool(StateNames::CORAL_HANG_TYPE_BIT) ? CoralType::FIRE : CoralType::BUBBLE));
|
||||||
$this->map(Ids::CORAL_FAN_HANG3, function(Reader $in) : Block{
|
$this->map(Ids::CORAL_FAN_HANG3, function(Reader $in) : Block{
|
||||||
$in->ignored(StateNames::CORAL_HANG_TYPE_BIT); //the game always writes this, even though it's not used
|
$in->ignored(StateNames::CORAL_HANG_TYPE_BIT); //the game always writes this, even though it's not used
|
||||||
return Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in)
|
return Helper::decodeWallCoralFan(Blocks::WALL_CORAL_FAN(), $in)
|
||||||
->setCoralType(CoralType::HORN());
|
->setCoralType(CoralType::HORN);
|
||||||
});
|
});
|
||||||
$this->mapStairs(Ids::DARK_PRISMARINE_STAIRS, fn() => Blocks::DARK_PRISMARINE_STAIRS());
|
$this->mapStairs(Ids::DARK_PRISMARINE_STAIRS, fn() => Blocks::DARK_PRISMARINE_STAIRS());
|
||||||
$this->map(Ids::DAYLIGHT_DETECTOR, fn(Reader $in) => Helper::decodeDaylightSensor(Blocks::DAYLIGHT_SENSOR(), $in)
|
$this->map(Ids::DAYLIGHT_DETECTOR, fn(Reader $in) => Helper::decodeDaylightSensor(Blocks::DAYLIGHT_SENSOR(), $in)
|
||||||
@ -986,12 +986,12 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
$this->map(Ids::DIRT, function(Reader $in) : Block{
|
$this->map(Ids::DIRT, function(Reader $in) : Block{
|
||||||
return Blocks::DIRT()
|
return Blocks::DIRT()
|
||||||
->setDirtType(match($value = $in->readString(StateNames::DIRT_TYPE)){
|
->setDirtType(match($value = $in->readString(StateNames::DIRT_TYPE)){
|
||||||
StringValues::DIRT_TYPE_NORMAL => DirtType::NORMAL(),
|
StringValues::DIRT_TYPE_NORMAL => DirtType::NORMAL,
|
||||||
StringValues::DIRT_TYPE_COARSE => DirtType::COARSE(),
|
StringValues::DIRT_TYPE_COARSE => DirtType::COARSE,
|
||||||
default => throw $in->badValueException(StateNames::DIRT_TYPE, $value),
|
default => throw $in->badValueException(StateNames::DIRT_TYPE, $value),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$this->map(Ids::DIRT_WITH_ROOTS, fn() => Blocks::DIRT()->setDirtType(DirtType::ROOTED()));
|
$this->map(Ids::DIRT_WITH_ROOTS, fn() => Blocks::DIRT()->setDirtType(DirtType::ROOTED));
|
||||||
$this->map(Ids::DOUBLE_PLANT, function(Reader $in) : Block{
|
$this->map(Ids::DOUBLE_PLANT, function(Reader $in) : Block{
|
||||||
return (match($type = $in->readString(StateNames::DOUBLE_PLANT_TYPE)){
|
return (match($type = $in->readString(StateNames::DOUBLE_PLANT_TYPE)){
|
||||||
StringValues::DOUBLE_PLANT_TYPE_FERN => Blocks::LARGE_FERN(),
|
StringValues::DOUBLE_PLANT_TYPE_FERN => Blocks::LARGE_FERN(),
|
||||||
@ -1017,10 +1017,10 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
return Blocks::ENDER_CHEST()
|
return Blocks::ENDER_CHEST()
|
||||||
->setFacing($in->readHorizontalFacing());
|
->setFacing($in->readHorizontalFacing());
|
||||||
});
|
});
|
||||||
$this->map(Ids::EXPOSED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::EXPOSED()));
|
$this->map(Ids::EXPOSED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::EXPOSED));
|
||||||
$this->map(Ids::EXPOSED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::EXPOSED()));
|
$this->map(Ids::EXPOSED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::EXPOSED));
|
||||||
$this->mapSlab(Ids::EXPOSED_CUT_COPPER_SLAB, Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::EXPOSED()));
|
$this->mapSlab(Ids::EXPOSED_CUT_COPPER_SLAB, Ids::EXPOSED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::EXPOSED));
|
||||||
$this->mapStairs(Ids::EXPOSED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::EXPOSED()));
|
$this->mapStairs(Ids::EXPOSED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::EXPOSED));
|
||||||
$this->map(Ids::FARMLAND, function(Reader $in) : Block{
|
$this->map(Ids::FARMLAND, function(Reader $in) : Block{
|
||||||
return Blocks::FARMLAND()
|
return Blocks::FARMLAND()
|
||||||
->setWetness($in->readBoundedInt(StateNames::MOISTURIZED_AMOUNT, 0, 7));
|
->setWetness($in->readBoundedInt(StateNames::MOISTURIZED_AMOUNT, 0, 7));
|
||||||
@ -1091,14 +1091,14 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
return Blocks::LEVER()
|
return Blocks::LEVER()
|
||||||
->setActivated($in->readBool(StateNames::OPEN_BIT))
|
->setActivated($in->readBool(StateNames::OPEN_BIT))
|
||||||
->setFacing(match($value = $in->readString(StateNames::LEVER_DIRECTION)){
|
->setFacing(match($value = $in->readString(StateNames::LEVER_DIRECTION)){
|
||||||
StringValues::LEVER_DIRECTION_DOWN_NORTH_SOUTH => LeverFacing::DOWN_AXIS_Z(),
|
StringValues::LEVER_DIRECTION_DOWN_NORTH_SOUTH => LeverFacing::DOWN_AXIS_Z,
|
||||||
StringValues::LEVER_DIRECTION_DOWN_EAST_WEST => LeverFacing::DOWN_AXIS_X(),
|
StringValues::LEVER_DIRECTION_DOWN_EAST_WEST => LeverFacing::DOWN_AXIS_X,
|
||||||
StringValues::LEVER_DIRECTION_UP_NORTH_SOUTH => LeverFacing::UP_AXIS_Z(),
|
StringValues::LEVER_DIRECTION_UP_NORTH_SOUTH => LeverFacing::UP_AXIS_Z,
|
||||||
StringValues::LEVER_DIRECTION_UP_EAST_WEST => LeverFacing::UP_AXIS_X(),
|
StringValues::LEVER_DIRECTION_UP_EAST_WEST => LeverFacing::UP_AXIS_X,
|
||||||
StringValues::LEVER_DIRECTION_NORTH => LeverFacing::NORTH(),
|
StringValues::LEVER_DIRECTION_NORTH => LeverFacing::NORTH,
|
||||||
StringValues::LEVER_DIRECTION_SOUTH => LeverFacing::SOUTH(),
|
StringValues::LEVER_DIRECTION_SOUTH => LeverFacing::SOUTH,
|
||||||
StringValues::LEVER_DIRECTION_WEST => LeverFacing::WEST(),
|
StringValues::LEVER_DIRECTION_WEST => LeverFacing::WEST,
|
||||||
StringValues::LEVER_DIRECTION_EAST => LeverFacing::EAST(),
|
StringValues::LEVER_DIRECTION_EAST => LeverFacing::EAST,
|
||||||
default => throw $in->badValueException(StateNames::LEVER_DIRECTION, $value),
|
default => throw $in->badValueException(StateNames::LEVER_DIRECTION, $value),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1170,12 +1170,12 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
->setAge($in->readBoundedInt(StateNames::AGE, 0, 3));
|
->setAge($in->readBoundedInt(StateNames::AGE, 0, 3));
|
||||||
});
|
});
|
||||||
$this->mapStairs(Ids::NORMAL_STONE_STAIRS, fn() => Blocks::STONE_STAIRS());
|
$this->mapStairs(Ids::NORMAL_STONE_STAIRS, fn() => Blocks::STONE_STAIRS());
|
||||||
$this->map(Ids::OCHRE_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::OCHRE())->setAxis($in->readPillarAxis()));
|
$this->map(Ids::OCHRE_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::OCHRE)->setAxis($in->readPillarAxis()));
|
||||||
$this->map(Ids::OXIDIZED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::OXIDIZED()));
|
$this->map(Ids::OXIDIZED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::OXIDIZED));
|
||||||
$this->map(Ids::OXIDIZED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::OXIDIZED()));
|
$this->map(Ids::OXIDIZED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::OXIDIZED));
|
||||||
$this->mapSlab(Ids::OXIDIZED_CUT_COPPER_SLAB, Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::OXIDIZED()));
|
$this->mapSlab(Ids::OXIDIZED_CUT_COPPER_SLAB, Ids::OXIDIZED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::OXIDIZED));
|
||||||
$this->mapStairs(Ids::OXIDIZED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::OXIDIZED()));
|
$this->mapStairs(Ids::OXIDIZED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::OXIDIZED));
|
||||||
$this->map(Ids::PEARLESCENT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::PEARLESCENT())->setAxis($in->readPillarAxis()));
|
$this->map(Ids::PEARLESCENT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::PEARLESCENT)->setAxis($in->readPillarAxis()));
|
||||||
$this->map(Ids::PINK_PETALS, function(Reader $in) : Block{
|
$this->map(Ids::PINK_PETALS, function(Reader $in) : Block{
|
||||||
//Pink petals only uses 0-3, but GROWTH state can go up to 7
|
//Pink petals only uses 0-3, but GROWTH state can go up to 7
|
||||||
$growth = $in->readBoundedInt(StateNames::GROWTH, 0, 7);
|
$growth = $in->readBoundedInt(StateNames::GROWTH, 0, 7);
|
||||||
@ -1493,7 +1493,7 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
$this->map(Ids::UNPOWERED_COMPARATOR, fn(Reader $in) => Helper::decodeComparator(Blocks::REDSTONE_COMPARATOR(), $in));
|
$this->map(Ids::UNPOWERED_COMPARATOR, fn(Reader $in) => Helper::decodeComparator(Blocks::REDSTONE_COMPARATOR(), $in));
|
||||||
$this->map(Ids::UNPOWERED_REPEATER, fn(Reader $in) => Helper::decodeRepeater(Blocks::REDSTONE_REPEATER(), $in)
|
$this->map(Ids::UNPOWERED_REPEATER, fn(Reader $in) => Helper::decodeRepeater(Blocks::REDSTONE_REPEATER(), $in)
|
||||||
->setPowered(false));
|
->setPowered(false));
|
||||||
$this->map(Ids::VERDANT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::VERDANT())->setAxis($in->readPillarAxis()));
|
$this->map(Ids::VERDANT_FROGLIGHT, fn(Reader $in) => Blocks::FROGLIGHT()->setFroglightType(FroglightType::VERDANT)->setAxis($in->readPillarAxis()));
|
||||||
$this->map(Ids::VINE, function(Reader $in) : Block{
|
$this->map(Ids::VINE, function(Reader $in) : Block{
|
||||||
$vineDirectionFlags = $in->readBoundedInt(StateNames::VINE_DIRECTION_BITS, 0, 15);
|
$vineDirectionFlags = $in->readBoundedInt(StateNames::VINE_DIRECTION_BITS, 0, 15);
|
||||||
return Blocks::VINES()
|
return Blocks::VINES()
|
||||||
@ -1507,26 +1507,26 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
|||||||
->setFacing($in->readHorizontalFacing());
|
->setFacing($in->readHorizontalFacing());
|
||||||
});
|
});
|
||||||
$this->map(Ids::WATER, fn(Reader $in) => Helper::decodeStillLiquid(Blocks::WATER(), $in));
|
$this->map(Ids::WATER, fn(Reader $in) => Helper::decodeStillLiquid(Blocks::WATER(), $in));
|
||||||
$this->map(Ids::WAXED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::NONE()));
|
$this->map(Ids::WAXED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::NONE));
|
||||||
$this->map(Ids::WAXED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE()));
|
$this->map(Ids::WAXED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::NONE));
|
||||||
$this->mapSlab(Ids::WAXED_CUT_COPPER_SLAB, Ids::WAXED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE()));
|
$this->mapSlab(Ids::WAXED_CUT_COPPER_SLAB, Ids::WAXED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::NONE));
|
||||||
$this->mapStairs(Ids::WAXED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE()));
|
$this->mapStairs(Ids::WAXED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::NONE));
|
||||||
$this->map(Ids::WAXED_EXPOSED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::EXPOSED()));
|
$this->map(Ids::WAXED_EXPOSED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::EXPOSED));
|
||||||
$this->map(Ids::WAXED_EXPOSED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::EXPOSED()));
|
$this->map(Ids::WAXED_EXPOSED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::EXPOSED));
|
||||||
$this->mapSlab(Ids::WAXED_EXPOSED_CUT_COPPER_SLAB, Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::EXPOSED()));
|
$this->mapSlab(Ids::WAXED_EXPOSED_CUT_COPPER_SLAB, Ids::WAXED_EXPOSED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::EXPOSED));
|
||||||
$this->mapStairs(Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::EXPOSED()));
|
$this->mapStairs(Ids::WAXED_EXPOSED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::EXPOSED));
|
||||||
$this->map(Ids::WAXED_OXIDIZED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::OXIDIZED()));
|
$this->map(Ids::WAXED_OXIDIZED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::OXIDIZED));
|
||||||
$this->map(Ids::WAXED_OXIDIZED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::OXIDIZED()));
|
$this->map(Ids::WAXED_OXIDIZED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::OXIDIZED));
|
||||||
$this->mapSlab(Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB, Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::OXIDIZED()));
|
$this->mapSlab(Ids::WAXED_OXIDIZED_CUT_COPPER_SLAB, Ids::WAXED_OXIDIZED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::OXIDIZED));
|
||||||
$this->mapStairs(Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::OXIDIZED()));
|
$this->mapStairs(Ids::WAXED_OXIDIZED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::OXIDIZED));
|
||||||
$this->map(Ids::WAXED_WEATHERED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::WEATHERED()));
|
$this->map(Ids::WAXED_WEATHERED_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::COPPER(), CopperOxidation::WEATHERED));
|
||||||
$this->map(Ids::WAXED_WEATHERED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::WEATHERED()));
|
$this->map(Ids::WAXED_WEATHERED_CUT_COPPER, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER(), CopperOxidation::WEATHERED));
|
||||||
$this->mapSlab(Ids::WAXED_WEATHERED_CUT_COPPER_SLAB, Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::WEATHERED()));
|
$this->mapSlab(Ids::WAXED_WEATHERED_CUT_COPPER_SLAB, Ids::WAXED_WEATHERED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::WEATHERED));
|
||||||
$this->mapStairs(Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::WEATHERED()));
|
$this->mapStairs(Ids::WAXED_WEATHERED_CUT_COPPER_STAIRS, fn() => Helper::decodeWaxedCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::WEATHERED));
|
||||||
$this->map(Ids::WEATHERED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::WEATHERED()));
|
$this->map(Ids::WEATHERED_COPPER, fn() => Helper::decodeCopper(Blocks::COPPER(), CopperOxidation::WEATHERED));
|
||||||
$this->map(Ids::WEATHERED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::WEATHERED()));
|
$this->map(Ids::WEATHERED_CUT_COPPER, fn() => Helper::decodeCopper(Blocks::CUT_COPPER(), CopperOxidation::WEATHERED));
|
||||||
$this->mapSlab(Ids::WEATHERED_CUT_COPPER_SLAB, Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::WEATHERED()));
|
$this->mapSlab(Ids::WEATHERED_CUT_COPPER_SLAB, Ids::WEATHERED_DOUBLE_CUT_COPPER_SLAB, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_SLAB(), CopperOxidation::WEATHERED));
|
||||||
$this->mapStairs(Ids::WEATHERED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::WEATHERED()));
|
$this->mapStairs(Ids::WEATHERED_CUT_COPPER_STAIRS, fn() => Helper::decodeCopper(Blocks::CUT_COPPER_STAIRS(), CopperOxidation::WEATHERED));
|
||||||
$this->map(Ids::WEEPING_VINES, function(Reader $in) : Block{
|
$this->map(Ids::WEEPING_VINES, function(Reader $in) : Block{
|
||||||
return Blocks::WEEPING_VINES()
|
return Blocks::WEEPING_VINES()
|
||||||
->setAge($in->readBoundedInt(StateNames::WEEPING_VINES_AGE, 0, 25));
|
->setAge($in->readBoundedInt(StateNames::WEEPING_VINES_AGE, 0, 25));
|
||||||
|
@ -246,10 +246,10 @@ final class BlockStateWriter{
|
|||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function writeSlabPosition(SlabType $slabType) : self{
|
public function writeSlabPosition(SlabType $slabType) : self{
|
||||||
$this->writeBool(BlockStateNames::TOP_SLOT_BIT, match($slabType->id()){
|
$this->writeBool(BlockStateNames::TOP_SLOT_BIT, match($slabType){
|
||||||
SlabType::TOP()->id() => true,
|
SlabType::TOP => true,
|
||||||
SlabType::BOTTOM()->id() => false,
|
SlabType::BOTTOM => false,
|
||||||
default => throw new BlockStateSerializeException("Invalid slab type " . $slabType->name())
|
default => throw new BlockStateSerializeException("Invalid slab type " . $slabType->name)
|
||||||
});
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -270,39 +270,37 @@ final class BlockStateWriter{
|
|||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function writeLegacyWoodType(WoodType $treeType) : self{
|
public function writeLegacyWoodType(WoodType $treeType) : self{
|
||||||
$this->writeString(BlockStateNames::WOOD_TYPE, match($treeType->id()){
|
$this->writeString(BlockStateNames::WOOD_TYPE, match($treeType){
|
||||||
WoodType::OAK()->id() => StringValues::WOOD_TYPE_OAK,
|
WoodType::OAK => StringValues::WOOD_TYPE_OAK,
|
||||||
WoodType::SPRUCE()->id() => StringValues::WOOD_TYPE_SPRUCE,
|
WoodType::SPRUCE => StringValues::WOOD_TYPE_SPRUCE,
|
||||||
WoodType::BIRCH()->id() => StringValues::WOOD_TYPE_BIRCH,
|
WoodType::BIRCH => StringValues::WOOD_TYPE_BIRCH,
|
||||||
WoodType::JUNGLE()->id() => StringValues::WOOD_TYPE_JUNGLE,
|
WoodType::JUNGLE => StringValues::WOOD_TYPE_JUNGLE,
|
||||||
WoodType::ACACIA()->id() => StringValues::WOOD_TYPE_ACACIA,
|
WoodType::ACACIA => StringValues::WOOD_TYPE_ACACIA,
|
||||||
WoodType::DARK_OAK()->id() => StringValues::WOOD_TYPE_DARK_OAK,
|
WoodType::DARK_OAK => StringValues::WOOD_TYPE_DARK_OAK,
|
||||||
default => throw new BlockStateSerializeException("Invalid Wood type " . $treeType->name())
|
default => throw new BlockStateSerializeException("Invalid legacy wood type " . $treeType->name)
|
||||||
});
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function writeCoralType(CoralType $coralType) : self{
|
public function writeCoralType(CoralType $coralType) : self{
|
||||||
$this->writeString(BlockStateNames::CORAL_COLOR, match($coralType->id()){
|
$this->writeString(BlockStateNames::CORAL_COLOR, match($coralType){
|
||||||
CoralType::TUBE()->id() => StringValues::CORAL_COLOR_BLUE,
|
CoralType::TUBE => StringValues::CORAL_COLOR_BLUE,
|
||||||
CoralType::BRAIN()->id() => StringValues::CORAL_COLOR_PINK,
|
CoralType::BRAIN => StringValues::CORAL_COLOR_PINK,
|
||||||
CoralType::BUBBLE()->id() => StringValues::CORAL_COLOR_PURPLE,
|
CoralType::BUBBLE => StringValues::CORAL_COLOR_PURPLE,
|
||||||
CoralType::FIRE()->id() => StringValues::CORAL_COLOR_RED,
|
CoralType::FIRE => StringValues::CORAL_COLOR_RED,
|
||||||
CoralType::HORN()->id() => StringValues::CORAL_COLOR_YELLOW,
|
CoralType::HORN => StringValues::CORAL_COLOR_YELLOW,
|
||||||
default => throw new BlockStateSerializeException("Invalid Coral type " . $coralType->name())
|
|
||||||
});
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function writeBellAttachmentType(BellAttachmentType $attachmentType) : self{
|
public function writeBellAttachmentType(BellAttachmentType $attachmentType) : self{
|
||||||
$this->writeString(BlockStateNames::ATTACHMENT, match($attachmentType->id()){
|
$this->writeString(BlockStateNames::ATTACHMENT, match($attachmentType){
|
||||||
BellAttachmentType::FLOOR()->id() => StringValues::ATTACHMENT_STANDING,
|
BellAttachmentType::FLOOR => StringValues::ATTACHMENT_STANDING,
|
||||||
BellAttachmentType::CEILING()->id() => StringValues::ATTACHMENT_HANGING,
|
BellAttachmentType::CEILING => StringValues::ATTACHMENT_HANGING,
|
||||||
BellAttachmentType::ONE_WALL()->id() => StringValues::ATTACHMENT_SIDE,
|
BellAttachmentType::ONE_WALL => StringValues::ATTACHMENT_SIDE,
|
||||||
BellAttachmentType::TWO_WALLS()->id() => StringValues::ATTACHMENT_MULTIPLE,
|
BellAttachmentType::TWO_WALLS => StringValues::ATTACHMENT_MULTIPLE,
|
||||||
default => throw new BlockStateSerializeException("Invalid Bell attachment type " . $attachmentType->name())
|
|
||||||
});
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -311,9 +309,8 @@ final class BlockStateWriter{
|
|||||||
public function writeWallConnectionType(string $name, ?WallConnectionType $wallConnectionType) : self{
|
public function writeWallConnectionType(string $name, ?WallConnectionType $wallConnectionType) : self{
|
||||||
$this->writeString($name, match($wallConnectionType){
|
$this->writeString($name, match($wallConnectionType){
|
||||||
null => StringValues::WALL_CONNECTION_TYPE_EAST_NONE,
|
null => StringValues::WALL_CONNECTION_TYPE_EAST_NONE,
|
||||||
WallConnectionType::SHORT() => StringValues::WALL_CONNECTION_TYPE_EAST_SHORT,
|
WallConnectionType::SHORT => StringValues::WALL_CONNECTION_TYPE_EAST_SHORT,
|
||||||
WallConnectionType::TALL() => StringValues::WALL_CONNECTION_TYPE_EAST_TALL,
|
WallConnectionType::TALL => StringValues::WALL_CONNECTION_TYPE_EAST_TALL,
|
||||||
default => throw new BlockStateSerializeException("Invalid Wall connection type " . $wallConnectionType->name())
|
|
||||||
});
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ use pocketmine\math\Axis;
|
|||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use pocketmine\utils\AssumptionFailedError;
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
use function intdiv;
|
use function intdiv;
|
||||||
|
use function spl_object_id;
|
||||||
|
|
||||||
final class RuntimeDataReader implements RuntimeDataDescriber{
|
final class RuntimeDataReader implements RuntimeDataDescriber{
|
||||||
use RuntimeEnumDeserializerTrait;
|
use RuntimeEnumDeserializerTrait;
|
||||||
@ -165,8 +166,8 @@ final class RuntimeDataReader implements RuntimeDataDescriber{
|
|||||||
$type = intdiv($packed, (3 ** $offset)) % 3;
|
$type = intdiv($packed, (3 ** $offset)) % 3;
|
||||||
if($type !== 0){
|
if($type !== 0){
|
||||||
$result[$facing] = match($type){
|
$result[$facing] = match($type){
|
||||||
1 => WallConnectionType::SHORT(),
|
1 => WallConnectionType::SHORT,
|
||||||
2 => WallConnectionType::TALL(),
|
2 => WallConnectionType::TALL,
|
||||||
default => throw new AssumptionFailedError("Unreachable")
|
default => throw new AssumptionFailedError("Unreachable")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -182,13 +183,9 @@ final class RuntimeDataReader implements RuntimeDataDescriber{
|
|||||||
*/
|
*/
|
||||||
public function brewingStandSlots(array &$slots) : void{
|
public function brewingStandSlots(array &$slots) : void{
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach([
|
foreach(BrewingStandSlot::cases() as $member){
|
||||||
BrewingStandSlot::EAST(),
|
|
||||||
BrewingStandSlot::NORTHWEST(),
|
|
||||||
BrewingStandSlot::SOUTHWEST(),
|
|
||||||
] as $member){
|
|
||||||
if($this->readBool()){
|
if($this->readBool()){
|
||||||
$result[$member->id()] = $member;
|
$result[spl_object_id($member)] = $member;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function brewingStandSlots(array &$slots) : void{
|
public function brewingStandSlots(array &$slots) : void{
|
||||||
$this->addBits(count(BrewingStandSlot::getAll()));
|
$this->addBits(count(BrewingStandSlot::cases()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function railShape(int &$railShape) : void{
|
public function railShape(int &$railShape) : void{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user