diff --git a/src/block/VanillaBlocks.php b/src/block/VanillaBlocks.php index 196816b30..8e5083f4b 100644 --- a/src/block/VanillaBlocks.php +++ b/src/block/VanillaBlocks.php @@ -750,8 +750,8 @@ use function strtolower; * @method static Water WATER() * @method static WaterCauldron WATER_CAULDRON() * @method static NetherVines WEEPING_VINES() - * @method static WeightedPressurePlateHeavy WEIGHTED_PRESSURE_PLATE_HEAVY() - * @method static WeightedPressurePlateLight WEIGHTED_PRESSURE_PLATE_LIGHT() + * @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_HEAVY() + * @method static WeightedPressurePlate WEIGHTED_PRESSURE_PLATE_LIGHT() * @method static Wheat WHEAT() * @method static Flower WHITE_TULIP() * @method static WitherRose WITHER_ROSE() @@ -1115,14 +1115,14 @@ final class VanillaBlocks{ self::register("lily_pad", new WaterLily(new BID(Ids::LILY_PAD), "Lily Pad", new Info(BreakInfo::instant()))); $weightedPressurePlateBreakInfo = new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD)); - self::register("weighted_pressure_plate_heavy", new WeightedPressurePlateHeavy( + self::register("weighted_pressure_plate_heavy", new WeightedPressurePlate( new BID(Ids::WEIGHTED_PRESSURE_PLATE_HEAVY), "Weighted Pressure Plate Heavy", $weightedPressurePlateBreakInfo, deactivationDelayTicks: 10, signalStrengthFactor: 0.1 )); - self::register("weighted_pressure_plate_light", new WeightedPressurePlateLight( + self::register("weighted_pressure_plate_light", new WeightedPressurePlate( new BID(Ids::WEIGHTED_PRESSURE_PLATE_LIGHT), "Weighted Pressure Plate Light", $weightedPressurePlateBreakInfo, diff --git a/src/block/WeightedPressurePlateHeavy.php b/src/block/WeightedPressurePlateHeavy.php deleted file mode 100644 index 9a8d1c31b..000000000 --- a/src/block/WeightedPressurePlateHeavy.php +++ /dev/null @@ -1,31 +0,0 @@ -writeInt(StateNames::WEEPING_VINES_AGE, $block->getAge()); }); - $this->map(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), function(WeightedPressurePlateHeavy $block) : Writer{ + $this->map(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), function(WeightedPressurePlate $block) : Writer{ return Writer::create(Ids::HEAVY_WEIGHTED_PRESSURE_PLATE) ->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength()); }); - $this->map(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), function(WeightedPressurePlateLight $block) : Writer{ + $this->map(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), function(WeightedPressurePlate $block) : Writer{ return Writer::create(Ids::LIGHT_WEIGHTED_PRESSURE_PLATE) ->writeInt(StateNames::REDSTONE_SIGNAL, $block->getOutputSignalStrength()); }); diff --git a/src/data/runtime/LegacyRuntimeEnumDescriberTrait.php b/src/data/runtime/LegacyRuntimeEnumDescriberTrait.php deleted file mode 100644 index dd35fabfb..000000000 --- a/src/data/runtime/LegacyRuntimeEnumDescriberTrait.php +++ /dev/null @@ -1,94 +0,0 @@ -enum($value); - } - - public function copperOxidation(\pocketmine\block\utils\CopperOxidation &$value) : void{ - $this->enum($value); - } - - public function coralType(\pocketmine\block\utils\CoralType &$value) : void{ - $this->enum($value); - } - - public function dirtType(\pocketmine\block\utils\DirtType &$value) : void{ - $this->enum($value); - } - - public function dripleafState(\pocketmine\block\utils\DripleafState &$value) : void{ - $this->enum($value); - } - - public function dyeColor(\pocketmine\block\utils\DyeColor &$value) : void{ - $this->enum($value); - } - - public function froglightType(\pocketmine\block\utils\FroglightType &$value) : void{ - $this->enum($value); - } - - public function leverFacing(\pocketmine\block\utils\LeverFacing &$value) : void{ - $this->enum($value); - } - - public function medicineType(\pocketmine\item\MedicineType &$value) : void{ - $this->enum($value); - } - - public function mobHeadType(\pocketmine\block\utils\MobHeadType &$value) : void{ - $this->enum($value); - } - - public function mushroomBlockType(\pocketmine\block\utils\MushroomBlockType &$value) : void{ - $this->enum($value); - } - - public function potionType(\pocketmine\item\PotionType &$value) : void{ - $this->enum($value); - } - - public function slabType(\pocketmine\block\utils\SlabType &$value) : void{ - $this->enum($value); - } - - public function suspiciousStewType(\pocketmine\item\SuspiciousStewType &$value) : void{ - $this->enum($value); - } -} diff --git a/src/data/runtime/RuntimeDataDescriber.php b/src/data/runtime/RuntimeDataDescriber.php index 2d8c52ec2..13de66eba 100644 --- a/src/data/runtime/RuntimeDataDescriber.php +++ b/src/data/runtime/RuntimeDataDescriber.php @@ -35,7 +35,7 @@ use pocketmine\math\Facing; * You may use it as a type for parameters and return values, but it should not be implemented outside of this package. * New methods may be added without warning. */ -interface RuntimeDataDescriber extends RuntimeEnumDescriber{ +interface RuntimeDataDescriber{ public function int(int $bits, int &$value) : void; public function boundedInt(int $bits, int $min, int $max, int &$value) : void; diff --git a/src/data/runtime/RuntimeDataReader.php b/src/data/runtime/RuntimeDataReader.php index 9b6445073..1c75eae21 100644 --- a/src/data/runtime/RuntimeDataReader.php +++ b/src/data/runtime/RuntimeDataReader.php @@ -34,8 +34,6 @@ use function intdiv; use function spl_object_id; final class RuntimeDataReader implements RuntimeDataDescriber{ - use LegacyRuntimeEnumDescriberTrait; - private int $offset = 0; public function __construct( diff --git a/src/data/runtime/RuntimeDataSizeCalculator.php b/src/data/runtime/RuntimeDataSizeCalculator.php index 82e360213..2594d7d9a 100644 --- a/src/data/runtime/RuntimeDataSizeCalculator.php +++ b/src/data/runtime/RuntimeDataSizeCalculator.php @@ -28,8 +28,6 @@ use pocketmine\math\Facing; use function count; final class RuntimeDataSizeCalculator implements RuntimeDataDescriber{ - use LegacyRuntimeEnumDescriberTrait; - private int $bits = 0; protected function addBits(int $bits) : void{ diff --git a/src/data/runtime/RuntimeDataWriter.php b/src/data/runtime/RuntimeDataWriter.php index 9e78875ea..2fb11fc87 100644 --- a/src/data/runtime/RuntimeDataWriter.php +++ b/src/data/runtime/RuntimeDataWriter.php @@ -31,8 +31,6 @@ use function array_flip; use function spl_object_id; final class RuntimeDataWriter implements RuntimeDataDescriber{ - use LegacyRuntimeEnumDescriberTrait; - private int $value = 0; private int $offset = 0; diff --git a/src/data/runtime/RuntimeEnumDescriber.php b/src/data/runtime/RuntimeEnumDescriber.php deleted file mode 100644 index 79550d041..000000000 --- a/src/data/runtime/RuntimeEnumDescriber.php +++ /dev/null @@ -1,61 +0,0 @@ -} */ enum PotionType{ - use LegacyEnumShimTrait; - case WATER; case MUNDANE; case LONG_MUNDANE; diff --git a/src/item/SuspiciousStewType.php b/src/item/SuspiciousStewType.php index d53b82a3f..52290a522 100644 --- a/src/item/SuspiciousStewType.php +++ b/src/item/SuspiciousStewType.php @@ -25,26 +25,8 @@ namespace pocketmine\item; use pocketmine\entity\effect\EffectInstance; use pocketmine\entity\effect\VanillaEffects; -use pocketmine\utils\LegacyEnumShimTrait; -/** - * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6) - * These are retained for backwards compatibility only. - * - * @method static SuspiciousStewType ALLIUM() - * @method static SuspiciousStewType AZURE_BLUET() - * @method static SuspiciousStewType BLUE_ORCHID() - * @method static SuspiciousStewType CORNFLOWER() - * @method static SuspiciousStewType DANDELION() - * @method static SuspiciousStewType LILY_OF_THE_VALLEY() - * @method static SuspiciousStewType OXEYE_DAISY() - * @method static SuspiciousStewType POPPY() - * @method static SuspiciousStewType TULIP() - * @method static SuspiciousStewType WITHER_ROSE() - */ enum SuspiciousStewType{ - use LegacyEnumShimTrait; - case POPPY; case CORNFLOWER; case TULIP; diff --git a/src/item/ToolTier.php b/src/item/ToolTier.php index 6c7161c33..e9282eb13 100644 --- a/src/item/ToolTier.php +++ b/src/item/ToolTier.php @@ -23,26 +23,10 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\utils\LegacyEnumShimTrait; - /** - * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever registry members are added, removed or changed. - * @see build/generate-registry-annotations.php - * @generate-registry-docblock - * - * @method static ToolTier DIAMOND() - * @method static ToolTier GOLD() - * @method static ToolTier IRON() - * @method static ToolTier NETHERITE() - * @method static ToolTier STONE() - * @method static ToolTier WOOD() - * * @phpstan-type TMetadata array{0: int, 1: int, 2: int, 3: int, 4: int} */ enum ToolTier{ - use LegacyEnumShimTrait; - case WOOD; case GOLD; case STONE; diff --git a/src/item/enchantment/Enchantment.php b/src/item/enchantment/Enchantment.php index 948f4648b..e8335d5f3 100644 --- a/src/item/enchantment/Enchantment.php +++ b/src/item/enchantment/Enchantment.php @@ -44,15 +44,11 @@ class Enchantment{ /** * @phpstan-param null|(\Closure(int $level) : int) $minEnchantingPower * - * @param int $primaryItemFlags @deprecated - * @param int $secondaryItemFlags @deprecated * @param int $enchantingPowerRange Value used to calculate the maximum enchanting power (minEnchantingPower + enchantingPowerRange) */ public function __construct( private Translatable|string $name, private int $rarity, - private int $primaryItemFlags, - private int $secondaryItemFlags, private int $maxLevel, ?\Closure $minEnchantingPower = null, private int $enchantingPowerRange = 50 @@ -79,47 +75,6 @@ class Enchantment{ return $this->rarity; } - /** - * Returns a bitset indicating what item types can have this item applied from an enchanting table. - * - * @deprecated - * @see AvailableEnchantmentRegistry::getPrimaryItemTags() - */ - public function getPrimaryItemFlags() : int{ - return $this->primaryItemFlags; - } - - /** - * Returns a bitset indicating what item types cannot have this item applied from an enchanting table, but can from - * an anvil. - * - * @deprecated - * @see AvailableEnchantmentRegistry::getSecondaryItemTags() - */ - public function getSecondaryItemFlags() : int{ - return $this->secondaryItemFlags; - } - - /** - * Returns whether this enchantment can apply to the item type from an enchanting table. - * - * @deprecated - * @see AvailableEnchantmentRegistry - */ - public function hasPrimaryItemType(int $flag) : bool{ - return ($this->primaryItemFlags & $flag) !== 0; - } - - /** - * Returns whether this enchantment can apply to the item type from an anvil, if it is not a primary item. - * - * @deprecated - * @see AvailableEnchantmentRegistry - */ - public function hasSecondaryItemType(int $flag) : bool{ - return ($this->secondaryItemFlags & $flag) !== 0; - } - /** * Returns the maximum level of this enchantment that can be found on an enchantment table. */ diff --git a/src/item/enchantment/ItemFlags.php b/src/item/enchantment/ItemFlags.php deleted file mode 100644 index 5e4ad4d7d..000000000 --- a/src/item/enchantment/ItemFlags.php +++ /dev/null @@ -1,54 +0,0 @@ -typeModifier = $typeModifier; if($applicableDamageTypes !== null){ diff --git a/src/item/enchantment/VanillaEnchantments.php b/src/item/enchantment/VanillaEnchantments.php index 779098c77..bfb9e3e92 100644 --- a/src/item/enchantment/VanillaEnchantments.php +++ b/src/item/enchantment/VanillaEnchantments.php @@ -62,8 +62,6 @@ final class VanillaEnchantments{ self::register("PROTECTION", new ProtectionEnchantment( KnownTranslationFactory::enchantment_protect_all(), Rarity::COMMON, - 0, - 0, 4, 0.75, null, @@ -73,8 +71,6 @@ final class VanillaEnchantments{ self::register("FIRE_PROTECTION", new ProtectionEnchantment( KnownTranslationFactory::enchantment_protect_fire(), Rarity::UNCOMMON, - 0, - 0, 4, 1.25, [ @@ -89,8 +85,6 @@ final class VanillaEnchantments{ self::register("FEATHER_FALLING", new ProtectionEnchantment( KnownTranslationFactory::enchantment_protect_fall(), Rarity::UNCOMMON, - 0, - 0, 4, 2.5, [ @@ -102,8 +96,6 @@ final class VanillaEnchantments{ self::register("BLAST_PROTECTION", new ProtectionEnchantment( KnownTranslationFactory::enchantment_protect_explosion(), Rarity::RARE, - 0, - 0, 4, 1.5, [ @@ -116,8 +108,6 @@ final class VanillaEnchantments{ self::register("PROJECTILE_PROTECTION", new ProtectionEnchantment( KnownTranslationFactory::enchantment_protect_projectile(), Rarity::UNCOMMON, - 0, - 0, 4, 1.5, [ @@ -129,8 +119,6 @@ final class VanillaEnchantments{ self::register("THORNS", new Enchantment( KnownTranslationFactory::enchantment_thorns(), Rarity::MYTHIC, - 0, - 0, 3, fn(int $level) : int => 20 * ($level - 1) + 10, 50 @@ -138,8 +126,6 @@ final class VanillaEnchantments{ self::register("RESPIRATION", new Enchantment( KnownTranslationFactory::enchantment_oxygen(), Rarity::RARE, - 0, - 0, 3, fn(int $level) : int => 10 * $level, 30 @@ -148,8 +134,6 @@ final class VanillaEnchantments{ self::register("SHARPNESS", new SharpnessEnchantment( KnownTranslationFactory::enchantment_damage_all(), Rarity::COMMON, - 0, - 0, 5, fn(int $level) : int => 11 * ($level - 1) + 1, 20 @@ -157,8 +141,6 @@ final class VanillaEnchantments{ self::register("KNOCKBACK", new KnockbackEnchantment( KnownTranslationFactory::enchantment_knockback(), Rarity::UNCOMMON, - 0, - 0, 2, fn(int $level) : int => 20 * ($level - 1) + 5, 50 @@ -166,8 +148,6 @@ final class VanillaEnchantments{ self::register("FIRE_ASPECT", new FireAspectEnchantment( KnownTranslationFactory::enchantment_fire(), Rarity::RARE, - 0, - 0, 2, fn(int $level) : int => 20 * ($level - 1) + 10, 50 @@ -177,8 +157,6 @@ final class VanillaEnchantments{ self::register("EFFICIENCY", new Enchantment( KnownTranslationFactory::enchantment_digging(), Rarity::COMMON, - 0, - 0, 5, fn(int $level) : int => 10 * ($level - 1) + 1, 50 @@ -186,8 +164,6 @@ final class VanillaEnchantments{ self::register("FORTUNE", new Enchantment( KnownTranslationFactory::enchantment_lootBonusDigger(), Rarity::RARE, - 0, - 0, 3, fn(int $level) : int => 9 * ($level - 1) + 15, 50 @@ -195,8 +171,6 @@ final class VanillaEnchantments{ self::register("SILK_TOUCH", new Enchantment( KnownTranslationFactory::enchantment_untouching(), Rarity::MYTHIC, - 0, - 0, 1, fn(int $level) : int => 15, 50 @@ -204,8 +178,6 @@ final class VanillaEnchantments{ self::register("UNBREAKING", new Enchantment( KnownTranslationFactory::enchantment_durability(), Rarity::UNCOMMON, - 0, - 0, 3, fn(int $level) : int => 8 * ($level - 1) + 5, 50 @@ -214,8 +186,6 @@ final class VanillaEnchantments{ self::register("POWER", new Enchantment( KnownTranslationFactory::enchantment_arrowDamage(), Rarity::COMMON, - 0, - 0, 5, fn(int $level) : int => 10 * ($level - 1) + 1, 15 @@ -223,8 +193,6 @@ final class VanillaEnchantments{ self::register("PUNCH", new Enchantment( KnownTranslationFactory::enchantment_arrowKnockback(), Rarity::RARE, - 0, - 0, 2, fn(int $level) : int => 20 * ($level - 1) + 12, 25 @@ -232,8 +200,6 @@ final class VanillaEnchantments{ self::register("FLAME", new Enchantment( KnownTranslationFactory::enchantment_arrowFire(), Rarity::RARE, - 0, - 0, 1, fn(int $level) : int => 20, 30 @@ -241,8 +207,6 @@ final class VanillaEnchantments{ self::register("INFINITY", new Enchantment( KnownTranslationFactory::enchantment_arrowInfinite(), Rarity::MYTHIC, - 0, - 0, 1, fn(int $level) : int => 20, 30 @@ -251,8 +215,6 @@ final class VanillaEnchantments{ self::register("MENDING", new Enchantment( KnownTranslationFactory::enchantment_mending(), Rarity::RARE, - 0, - 0, 1, fn(int $level) : int => 25, 50 @@ -261,8 +223,6 @@ final class VanillaEnchantments{ self::register("VANISHING", new Enchantment( KnownTranslationFactory::enchantment_curse_vanishing(), Rarity::MYTHIC, - 0, - 0, 1, fn(int $level) : int => 25, 25 @@ -271,8 +231,6 @@ final class VanillaEnchantments{ self::register("SWIFT_SNEAK", new Enchantment( KnownTranslationFactory::enchantment_swift_sneak(), Rarity::MYTHIC, - 0, - 0, 3, fn(int $level) : int => 10 * $level, 5 diff --git a/src/player/UsedChunkStatus.php b/src/player/UsedChunkStatus.php index dda41fe7e..ad80fe084 100644 --- a/src/player/UsedChunkStatus.php +++ b/src/player/UsedChunkStatus.php @@ -23,20 +23,7 @@ declare(strict_types=1); namespace pocketmine\player; -use pocketmine\utils\LegacyEnumShimTrait; - -/** - * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6) - * These are retained for backwards compatibility only. - * - * @method static UsedChunkStatus NEEDED() - * @method static UsedChunkStatus REQUESTED_GENERATION() - * @method static UsedChunkStatus REQUESTED_SENDING() - * @method static UsedChunkStatus SENT() - */ enum UsedChunkStatus{ - use LegacyEnumShimTrait; - case NEEDED; case REQUESTED_GENERATION; case REQUESTED_SENDING; diff --git a/src/utils/EnumTrait.php b/src/utils/EnumTrait.php index ee1bd4e35..e03ec1f06 100644 --- a/src/utils/EnumTrait.php +++ b/src/utils/EnumTrait.php @@ -30,8 +30,7 @@ namespace pocketmine\utils; * Classes using this trait need to include \@method tags in their class docblock for every enum member. * Alternatively, just put \@generate-registry-docblock in the docblock and run tools/generate-registry-annotations.php * - * @deprecated Use native PHP 8.1 enums instead. Use {@link LegacyEnumShimTrait} if you need to provide backwards - * compatible EnumTrait-like API for migrated enums. + * @deprecated Use native PHP 8.1 enums instead. */ trait EnumTrait{ use RegistryTrait; diff --git a/src/utils/LegacyEnumShimTrait.php b/src/utils/LegacyEnumShimTrait.php deleted file mode 100644 index 4bb3587ab..000000000 --- a/src/utils/LegacyEnumShimTrait.php +++ /dev/null @@ -1,92 +0,0 @@ - 0){ - throw new \ArgumentCountError("Expected exactly 0 arguments, " . count($arguments) . " passed"); - } - return self::getAll()[mb_strtoupper($name)]; - } - - /** - * Returns a list of all cases, indexed by name. - * - * @return self[] - * @phpstan-return array - */ - public static function getAll() : array{ - /** @var array|null $result */ - static $result = null; - if($result === null){ - $result = []; - foreach(self::cases() as $case){ - $result[mb_strtoupper($case->name)] = $case; - } - } - return $result; - } - - /** - * Shim for {@link \UnitEnum::name}. - * - * @deprecated Use the native enum's name property instead. - */ - public function name() : string{ - return $this->name; - } - - /** - * Alias of spl_object_id($this). - * - * @deprecated - */ - public function id() : int{ - return spl_object_id($this); - } - - /** - * Returns whether the two objects are equivalent. - * - * @deprecated Native enums can be safely compared with ===. - */ - public function equals(self $other) : bool{ - return $this === $other; - } -} diff --git a/src/world/generator/object/TreeType.php b/src/world/generator/object/TreeType.php index d4d62946a..62b933172 100644 --- a/src/world/generator/object/TreeType.php +++ b/src/world/generator/object/TreeType.php @@ -23,22 +23,7 @@ declare(strict_types=1); namespace pocketmine\world\generator\object; -use pocketmine\utils\LegacyEnumShimTrait; - -/** - * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6) - * These are retained for backwards compatibility only. - * - * @method static TreeType ACACIA() - * @method static TreeType BIRCH() - * @method static TreeType DARK_OAK() - * @method static TreeType JUNGLE() - * @method static TreeType OAK() - * @method static TreeType SPRUCE() - */ enum TreeType{ - use LegacyEnumShimTrait; - case OAK; case SPRUCE; case BIRCH; diff --git a/src/world/sound/NoteInstrument.php b/src/world/sound/NoteInstrument.php index a91d52cf7..2536467b4 100644 --- a/src/world/sound/NoteInstrument.php +++ b/src/world/sound/NoteInstrument.php @@ -23,32 +23,7 @@ declare(strict_types=1); namespace pocketmine\world\sound; -use pocketmine\utils\LegacyEnumShimTrait; - -/** - * TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6) - * These are retained for backwards compatibility only. - * - * @method static NoteInstrument BANJO() - * @method static NoteInstrument BASS_DRUM() - * @method static NoteInstrument BELL() - * @method static NoteInstrument BIT() - * @method static NoteInstrument CHIME() - * @method static NoteInstrument CLICKS_AND_STICKS() - * @method static NoteInstrument COW_BELL() - * @method static NoteInstrument DIDGERIDOO() - * @method static NoteInstrument DOUBLE_BASS() - * @method static NoteInstrument FLUTE() - * @method static NoteInstrument GUITAR() - * @method static NoteInstrument IRON_XYLOPHONE() - * @method static NoteInstrument PIANO() - * @method static NoteInstrument PLING() - * @method static NoteInstrument SNARE() - * @method static NoteInstrument XYLOPHONE() - */ enum NoteInstrument{ - use LegacyEnumShimTrait; - case PIANO; case BASS_DRUM; case SNARE;