Start migrating EnumTrait enums to PHP 8.1 native enums

This commit is contained in:
Dylan K. Taylor
2023-09-07 17:20:52 +01:00
parent fe94379a93
commit ae564e445d
131 changed files with 1157 additions and 1349 deletions

View File

@@ -150,7 +150,7 @@ class Armor extends Durable{
//if the stack size was bigger than 1 (usually won't happen, but might be caused by plugins)
$returnedItems[] = $thisCopy;
}
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
protected function deserializeCompoundTag(CompoundTag $tag) : void{

View File

@@ -24,13 +24,11 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\utils\WoodType;
use pocketmine\utils\EnumTrait;
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
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static BoatType ACACIA()
* @method static BoatType BIRCH()
@@ -40,33 +38,30 @@ use pocketmine\utils\EnumTrait;
* @method static BoatType OAK()
* @method static BoatType SPRUCE()
*/
final class BoatType{
use EnumTrait {
__construct as Enum___construct;
}
enum BoatType{
use LegacyEnumShimTrait;
protected static function setup() : void{
self::registerAll(
new self("oak", WoodType::OAK()),
new self("spruce", WoodType::SPRUCE()),
new self("birch", WoodType::BIRCH()),
new self("jungle", WoodType::JUNGLE()),
new self("acacia", WoodType::ACACIA()),
new self("dark_oak", WoodType::DARK_OAK()),
new self("mangrove", WoodType::MANGROVE()),
);
}
case OAK;
case SPRUCE;
case BIRCH;
case JUNGLE;
case ACACIA;
case DARK_OAK;
case MANGROVE;
private function __construct(
string $enumName,
private WoodType $woodType,
){
$this->Enum___construct($enumName);
public function getWoodType() : WoodType{
return match($this){
self::OAK => WoodType::OAK,
self::SPRUCE => WoodType::SPRUCE,
self::BIRCH => WoodType::BIRCH,
self::JUNGLE => WoodType::JUNGLE,
self::ACACIA => WoodType::ACACIA,
self::DARK_OAK => WoodType::DARK_OAK,
self::MANGROVE => WoodType::MANGROVE,
};
}
public function getWoodType() : WoodType{ return $this->woodType; }
public function getDisplayName() : string{
return $this->woodType->getDisplayName();
return $this->getWoodType()->getDisplayName();
}
}

View File

@@ -53,7 +53,7 @@ class Bow extends Tool implements Releasable{
};
if($player->hasFiniteResources() && $inventory === null){
return ItemUseResult::FAIL();
return ItemUseResult::FAIL;
}
$location = $player->getLocation();
@@ -95,7 +95,7 @@ class Bow extends Tool implements Releasable{
if($ev->isCancelled()){
$entity->flagForDespawn();
return ItemUseResult::FAIL();
return ItemUseResult::FAIL;
}
$entity->setMotion($entity->getMotion()->multiply($ev->getForce()));
@@ -105,7 +105,7 @@ class Bow extends Tool implements Releasable{
$projectileEv->call();
if($projectileEv->isCancelled()){
$ev->getProjectile()->flagForDespawn();
return ItemUseResult::FAIL();
return ItemUseResult::FAIL;
}
$ev->getProjectile()->spawnToAll();
@@ -121,7 +121,7 @@ class Bow extends Tool implements Releasable{
$this->applyDamage(1);
}
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
public function canStartUsingItem(Player $player) : bool{

View File

@@ -49,7 +49,7 @@ class Bucket extends Item{
default => null
};
if($resultItem === null){
return ItemUseResult::FAIL();
return ItemUseResult::FAIL;
}
$ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem);
@@ -60,12 +60,12 @@ class Bucket extends Item{
$this->pop();
$returnedItems[] = $ev->getItem();
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
return ItemUseResult::FAIL();
return ItemUseResult::FAIL;
}
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\CoralTypeTrait;
use pocketmine\block\VanillaBlocks;
use pocketmine\data\runtime\RuntimeDataDescriber;
@@ -37,7 +36,6 @@ final class CoralFan extends Item{
}
public function __construct(ItemIdentifier $identifier){
$this->coralType = CoralType::TUBE();
parent::__construct($identifier, VanillaBlocks::CORAL_FAN()->getName());
}

View File

@@ -40,9 +40,9 @@ class FireCharge extends Item{
$this->pop();
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
}

View File

@@ -40,10 +40,10 @@ class FlintSteel extends Tool{
$this->applyDamage(1);
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
public function getMaxDurability() : int{

View File

@@ -35,9 +35,9 @@ class GlassBottle extends Item{
$this->pop();
$returnedItems[] = VanillaItems::POTION()->setType(PotionType::WATER());
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
}

View File

@@ -588,7 +588,7 @@ class Item implements \JsonSerializable{
* @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if the inventory is full)
*/
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
/**
@@ -598,7 +598,7 @@ class Item implements \JsonSerializable{
* @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if the inventory is full)
*/
public function onClickAir(Player $player, Vector3 $directionVector, array &$returnedItems) : ItemUseResult{
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
/**
@@ -608,7 +608,7 @@ class Item implements \JsonSerializable{
* @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if the inventory is full)
*/
public function onReleaseUsing(Player $player, array &$returnedItems) : ItemUseResult{
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
/**

View File

@@ -23,26 +23,20 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\utils\EnumTrait;
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
* TODO: These tags need to be removed once we get rid of LegacyEnumShimTrait (PM6)
* These are retained for backwards compatibility only.
*
* @method static ItemUseResult FAIL()
* @method static ItemUseResult NONE()
* @method static ItemUseResult SUCCESS()
*/
final class ItemUseResult{
use EnumTrait;
enum ItemUseResult{
use LegacyEnumShimTrait;
protected static function setup() : void{
self::registerAll(
new self("none"),
new self("fail"),
new self("success")
);
}
case NONE;
case FAIL;
case SUCCESS;
}

View File

@@ -56,7 +56,7 @@ class LiquidBucket extends Item{
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{
if(!$blockReplace->canBeReplaced()){
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
//TODO: move this to generic placement logic
@@ -70,10 +70,10 @@ class LiquidBucket extends Item{
$this->pop();
$returnedItems[] = $ev->getItem();
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
return ItemUseResult::FAIL();
return ItemUseResult::FAIL;
}
public function getLiquid() : Liquid{

View File

@@ -39,7 +39,7 @@ class PaintingItem extends Item{
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{
if(Facing::axis($face) === Axis::Y){
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
$motives = [];
@@ -67,7 +67,7 @@ class PaintingItem extends Item{
}
if(count($motives) === 0){ //No space available
return ItemUseResult::NONE();
return ItemUseResult::NONE;
}
/** @var PaintingMotive $motive */
@@ -81,6 +81,6 @@ class PaintingItem extends Item{
$entity->spawnToAll();
$player->getWorld()->addSound($replacePos->add(0.5, 0.5, 0.5), new PaintingPlaceSound());
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
}

View File

@@ -46,7 +46,7 @@ abstract class ProjectileItem extends Item{
$projectileEv->call();
if($projectileEv->isCancelled()){
$projectile->flagForDespawn();
return ItemUseResult::FAIL();
return ItemUseResult::FAIL;
}
$projectile->spawnToAll();
@@ -55,6 +55,6 @@ abstract class ProjectileItem extends Item{
$this->pop();
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
}

View File

@@ -43,6 +43,6 @@ abstract class SpawnEgg extends Item{
$this->pop();
$entity->spawnToAll();
//TODO: what if the entity was marked for deletion?
return ItemUseResult::SUCCESS();
return ItemUseResult::SUCCESS;
}
}

View File

@@ -37,6 +37,7 @@ use pocketmine\item\VanillaItems as Items;
use pocketmine\utils\SingletonTrait;
use pocketmine\utils\StringToTParser;
use function array_keys;
use function strtolower;
/**
* Handles parsing items from strings. This is used to interpret names from the /give command (and others).
@@ -77,8 +78,8 @@ final class StringToItemParser extends StringToTParser{
$register("shulker_box", fn() => Blocks::DYED_SHULKER_BOX()->setColor($color));
}
foreach(CoralType::getAll() as $coralType){
$register = fn(string $name, \Closure $callback) => $result->registerBlock($coralType->name() . "_" . $name, $callback);
foreach(CoralType::cases() as $coralType){
$register = fn(string $name, \Closure $callback) => $result->registerBlock(strtolower($coralType->name) . "_" . $name, $callback);
$register("coral", fn() => Blocks::CORAL()->setCoralType($coralType));
$register("coral_block", fn() => Blocks::CORAL_BLOCK()->setCoralType($coralType));
//wall and floor coral fans are the same item
@@ -90,8 +91,8 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("light_block_$i", fn() => Blocks::LIGHT()->setLightLevel($i));
}
foreach(CopperOxidation::getAll() as $oxidation){
$oxPrefix = $oxidation->equals(CopperOxidation::NONE()) ? "" : $oxidation->name() . "_";
foreach(CopperOxidation::cases() as $oxidation){
$oxPrefix = $oxidation === CopperOxidation::NONE ? "" : strtolower($oxidation->name) . "_";
foreach(["" => false, "waxed_" => true] as $waxedPrefix => $waxed){
$register = fn(string $name, \Closure $callback) => $result->registerBlock($waxedPrefix . $oxPrefix . $name, $callback);
@@ -102,8 +103,8 @@ final class StringToItemParser extends StringToTParser{
}
}
foreach(FroglightType::getAll() as $froglightType){
$result->registerBlock($froglightType->name() . "_froglight", fn() => Blocks::FROGLIGHT()->setFroglightType($froglightType));
foreach(FroglightType::cases() as $froglightType){
$result->registerBlock(strtolower($froglightType->name) . "_froglight", fn() => Blocks::FROGLIGHT()->setFroglightType($froglightType));
}
}
@@ -238,7 +239,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("clay_block", fn() => Blocks::CLAY());
$result->registerBlock("coal_block", fn() => Blocks::COAL());
$result->registerBlock("coal_ore", fn() => Blocks::COAL_ORE());
$result->registerBlock("coarse_dirt", fn() => Blocks::DIRT()->setDirtType(DirtType::COARSE()));
$result->registerBlock("coarse_dirt", fn() => Blocks::DIRT()->setDirtType(DirtType::COARSE));
$result->registerBlock("cobble", fn() => Blocks::COBBLESTONE());
$result->registerBlock("cobble_stairs", fn() => Blocks::COBBLESTONE_STAIRS());
$result->registerBlock("cobble_wall", fn() => Blocks::COBBLESTONE_WALL());
@@ -267,10 +268,10 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("coral", fn() => Blocks::CORAL());
$result->registerBlock("coral_block", fn() => Blocks::CORAL_BLOCK());
$result->registerBlock("coral_fan", fn() => Blocks::CORAL_FAN());
$result->registerBlock("coral_fan_dead", fn() => Blocks::CORAL_FAN()->setCoralType(CoralType::TUBE())->setDead(true));
$result->registerBlock("coral_fan_dead", fn() => Blocks::CORAL_FAN()->setCoralType(CoralType::TUBE)->setDead(true));
$result->registerBlock("coral_fan_hang", fn() => Blocks::WALL_CORAL_FAN());
$result->registerBlock("coral_fan_hang2", fn() => Blocks::WALL_CORAL_FAN()->setCoralType(CoralType::BUBBLE()));
$result->registerBlock("coral_fan_hang3", fn() => Blocks::WALL_CORAL_FAN()->setCoralType(CoralType::HORN()));
$result->registerBlock("coral_fan_hang2", fn() => Blocks::WALL_CORAL_FAN()->setCoralType(CoralType::BUBBLE));
$result->registerBlock("coral_fan_hang3", fn() => Blocks::WALL_CORAL_FAN()->setCoralType(CoralType::HORN));
$result->registerBlock("cornflower", fn() => Blocks::CORNFLOWER());
$result->registerBlock("cracked_deepslate_bricks", fn() => Blocks::CRACKED_DEEPSLATE_BRICKS());
$result->registerBlock("cracked_deepslate_tiles", fn() => Blocks::CRACKED_DEEPSLATE_TILES());
@@ -278,7 +279,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("cracked_polished_blackstone_bricks", fn() => Blocks::CRACKED_POLISHED_BLACKSTONE_BRICKS());
$result->registerBlock("cracked_stone_bricks", fn() => Blocks::CRACKED_STONE_BRICKS());
$result->registerBlock("crafting_table", fn() => Blocks::CRAFTING_TABLE());
$result->registerBlock("creeper_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::CREEPER()));
$result->registerBlock("creeper_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::CREEPER));
$result->registerBlock("crimson_button", fn() => Blocks::CRIMSON_BUTTON());
$result->registerBlock("crimson_door", fn() => Blocks::CRIMSON_DOOR());
$result->registerBlock("crimson_fence", fn() => Blocks::CRIMSON_FENCE());
@@ -353,24 +354,24 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("diorite_slab", fn() => Blocks::DIORITE_SLAB());
$result->registerBlock("diorite_stairs", fn() => Blocks::DIORITE_STAIRS());
$result->registerBlock("diorite_wall", fn() => Blocks::DIORITE_WALL());
$result->registerBlock("dirt", fn() => Blocks::DIRT()->setDirtType(DirtType::NORMAL()));
$result->registerBlock("dirt_with_roots", fn() => Blocks::DIRT()->setDirtType(DirtType::ROOTED()));
$result->registerBlock("dirt", fn() => Blocks::DIRT()->setDirtType(DirtType::NORMAL));
$result->registerBlock("dirt_with_roots", fn() => Blocks::DIRT()->setDirtType(DirtType::ROOTED));
$result->registerBlock("door_block", fn() => Blocks::OAK_DOOR());
$result->registerBlock("double_plant", fn() => Blocks::SUNFLOWER());
$result->registerBlock("double_red_sandstone_slab", fn() => Blocks::RED_SANDSTONE_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_slab", fn() => Blocks::STONE_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_slabs", fn() => Blocks::STONE_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_stone_slab", fn() => Blocks::STONE_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_stone_slab2", fn() => Blocks::RED_SANDSTONE_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_stone_slab3", fn() => Blocks::END_STONE_BRICK_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_stone_slab4", fn() => Blocks::MOSSY_STONE_BRICK_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_red_sandstone_slab", fn() => Blocks::RED_SANDSTONE_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_slab", fn() => Blocks::STONE_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_slabs", fn() => Blocks::STONE_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_stone_slab", fn() => Blocks::STONE_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_stone_slab2", fn() => Blocks::RED_SANDSTONE_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_stone_slab3", fn() => Blocks::END_STONE_BRICK_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_stone_slab4", fn() => Blocks::MOSSY_STONE_BRICK_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_tallgrass", fn() => Blocks::DOUBLE_TALLGRASS());
$result->registerBlock("double_wood_slab", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_wood_slabs", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_wooden_slab", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_wooden_slabs", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE()));
$result->registerBlock("double_wood_slab", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_wood_slabs", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_wooden_slab", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("double_wooden_slabs", fn() => Blocks::OAK_SLAB()->setSlabType(SlabType::DOUBLE));
$result->registerBlock("dragon_egg", fn() => Blocks::DRAGON_EGG());
$result->registerBlock("dragon_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::DRAGON()));
$result->registerBlock("dragon_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::DRAGON));
$result->registerBlock("dried_kelp_block", fn() => Blocks::DRIED_KELP());
$result->registerBlock("dyed_shulker_box", fn() => Blocks::DYED_SHULKER_BOX());
$result->registerBlock("element_0", fn() => Blocks::ELEMENT_ZERO());
@@ -858,10 +859,10 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("peony", fn() => Blocks::PEONY());
$result->registerBlock("pink_petals", fn() => Blocks::PINK_PETALS());
$result->registerBlock("pink_tulip", fn() => Blocks::PINK_TULIP());
$result->registerBlock("piglin_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PIGLIN()));
$result->registerBlock("piglin_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PIGLIN));
$result->registerBlock("plank", fn() => Blocks::OAK_PLANKS());
$result->registerBlock("planks", fn() => Blocks::OAK_PLANKS());
$result->registerBlock("player_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PLAYER()));
$result->registerBlock("player_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PLAYER));
$result->registerBlock("podzol", fn() => Blocks::PODZOL());
$result->registerBlock("polished_andesite", fn() => Blocks::POLISHED_ANDESITE());
$result->registerBlock("polished_andesite_slab", fn() => Blocks::POLISHED_ANDESITE_SLAB());
@@ -950,7 +951,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("repeater", fn() => Blocks::REDSTONE_REPEATER());
$result->registerBlock("repeater_block", fn() => Blocks::REDSTONE_REPEATER());
$result->registerBlock("reserved6", fn() => Blocks::RESERVED6());
$result->registerBlock("rooted_dirt", fn() => Blocks::DIRT()->setDirtType(DirtType::ROOTED()));
$result->registerBlock("rooted_dirt", fn() => Blocks::DIRT()->setDirtType(DirtType::ROOTED));
$result->registerBlock("rose", fn() => Blocks::POPPY());
$result->registerBlock("rose_bush", fn() => Blocks::ROSE_BUSH());
$result->registerBlock("sand", fn() => Blocks::SAND());
@@ -967,8 +968,8 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("shulker_box", fn() => Blocks::SHULKER_BOX());
$result->registerBlock("sign", fn() => Blocks::OAK_SIGN());
$result->registerBlock("sign_post", fn() => Blocks::OAK_SIGN());
$result->registerBlock("skeleton_skull", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::SKELETON()));
$result->registerBlock("skull", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::SKELETON()));
$result->registerBlock("skeleton_skull", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::SKELETON));
$result->registerBlock("skull", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::SKELETON));
$result->registerBlock("skull_block", fn() => Blocks::MOB_HEAD());
$result->registerBlock("slab", fn() => Blocks::SMOOTH_STONE_SLAB());
$result->registerBlock("slabs", fn() => Blocks::SMOOTH_STONE_SLAB());
@@ -1119,7 +1120,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("wheat_block", fn() => Blocks::WHEAT());
$result->registerBlock("white_tulip", fn() => Blocks::WHITE_TULIP());
$result->registerBlock("wither_rose", fn() => Blocks::WITHER_ROSE());
$result->registerBlock("wither_skeleton_skull", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::WITHER_SKELETON()));
$result->registerBlock("wither_skeleton_skull", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::WITHER_SKELETON));
$result->registerBlock("wood", fn() => Blocks::OAK_LOG()->setStripped(false));
$result->registerBlock("wood2", fn() => Blocks::ACACIA_LOG()->setStripped(false));
$result->registerBlock("wood_door_block", fn() => Blocks::OAK_DOOR());
@@ -1139,7 +1140,7 @@ final class StringToItemParser extends StringToTParser{
$result->registerBlock("wool", fn() => Blocks::WOOL());
$result->registerBlock("workbench", fn() => Blocks::CRAFTING_TABLE());
$result->registerBlock("yellow_flower", fn() => Blocks::DANDELION());
$result->registerBlock("zombie_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::ZOMBIE()));
$result->registerBlock("zombie_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::ZOMBIE));
}
private static function registerDynamicItems(self $result) : void{

View File

@@ -36,9 +36,9 @@ use pocketmine\item\ItemIdentifier as IID;
use pocketmine\item\ItemTypeIds as Ids;
use pocketmine\item\VanillaArmorMaterials as ArmorMaterials;
use pocketmine\math\Vector3;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\CloningRegistryTrait;
use pocketmine\world\World;
use function strtolower;
/**
* This doc-block is generated automatically, do not modify it manually.
@@ -546,17 +546,16 @@ final class VanillaItems{
self::register("writable_book", new WritableBook(new IID(Ids::WRITABLE_BOOK), "Book & Quill"));
self::register("written_book", new WrittenBook(new IID(Ids::WRITTEN_BOOK), "Written Book"));
foreach(BoatType::getAll() as $type){
foreach(BoatType::cases() as $type){
//boat type is static, because different types of wood may have different properties
self::register($type->name() . "_boat", new Boat(new IID(match($type){
BoatType::OAK() => Ids::OAK_BOAT,
BoatType::SPRUCE() => Ids::SPRUCE_BOAT,
BoatType::BIRCH() => Ids::BIRCH_BOAT,
BoatType::JUNGLE() => Ids::JUNGLE_BOAT,
BoatType::ACACIA() => Ids::ACACIA_BOAT,
BoatType::DARK_OAK() => Ids::DARK_OAK_BOAT,
BoatType::MANGROVE() => Ids::MANGROVE_BOAT,
default => throw new AssumptionFailedError("Unhandled tree type " . $type->name())
self::register(strtolower($type->name) . "_boat", new Boat(new IID(match($type){
BoatType::OAK => Ids::OAK_BOAT,
BoatType::SPRUCE => Ids::SPRUCE_BOAT,
BoatType::BIRCH => Ids::BIRCH_BOAT,
BoatType::JUNGLE => Ids::JUNGLE_BOAT,
BoatType::ACACIA => Ids::ACACIA_BOAT,
BoatType::DARK_OAK => Ids::DARK_OAK_BOAT,
BoatType::MANGROVE => Ids::MANGROVE_BOAT,
}), $type->getDisplayName() . " Boat", $type));
}
}