From d596dc571da70079f3dc00631adac8ab81fb6ba4 Mon Sep 17 00:00:00 2001 From: ace Date: Mon, 27 Nov 2023 22:46:20 +0800 Subject: [PATCH] Fix pitcher pod wrongly registered as a block (#6162) --- src/block/DoublePitcherCrop.php | 11 ++++++ src/block/PitcherCrop.php | 5 +++ .../ItemSerializerDeserializerRegistrar.php | 2 +- src/item/ItemTypeIds.php | 3 +- src/item/PitcherPod.php | 34 +++++++++++++++++++ src/item/StringToItemParser.php | 2 +- src/item/VanillaItems.php | 2 ++ 7 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/item/PitcherPod.php diff --git a/src/block/DoublePitcherCrop.php b/src/block/DoublePitcherCrop.php index e34dd1baf..1233ed05d 100644 --- a/src/block/DoublePitcherCrop.php +++ b/src/block/DoublePitcherCrop.php @@ -29,6 +29,7 @@ use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\event\block\StructureGrowEvent; use pocketmine\item\Fertilizer; use pocketmine\item\Item; +use pocketmine\item\VanillaItems; use pocketmine\math\Axis; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; @@ -106,4 +107,14 @@ final class DoublePitcherCrop extends DoublePlant{ $this->grow(null); } } + + public function getDropsForCompatibleTool(Item $item) : array{ + return [ + $this->age >= self::MAX_AGE ? VanillaBlocks::PITCHER_PLANT()->asItem() : VanillaItems::PITCHER_POD() + ]; + } + + public function asItem() : Item{ + return VanillaItems::PITCHER_POD(); + } } diff --git a/src/block/PitcherCrop.php b/src/block/PitcherCrop.php index e0b9af3d2..d41aed284 100644 --- a/src/block/PitcherCrop.php +++ b/src/block/PitcherCrop.php @@ -30,6 +30,7 @@ use pocketmine\block\utils\StaticSupportTrait; use pocketmine\event\block\StructureGrowEvent; use pocketmine\item\Fertilizer; use pocketmine\item\Item; +use pocketmine\item\VanillaItems; use pocketmine\math\Axis; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; @@ -101,4 +102,8 @@ final class PitcherCrop extends Flowable{ $this->grow(null); } } + + public function asItem() : Item{ + return VanillaItems::PITCHER_POD(); + } } diff --git a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php index a2bed6ee1..0c6dadc46 100644 --- a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php +++ b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php @@ -147,7 +147,6 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Block(Ids::JUNGLE_DOOR, Blocks::JUNGLE_DOOR()); $this->map1to1Block(Ids::MANGROVE_DOOR, Blocks::MANGROVE_DOOR()); $this->map1to1Block(Ids::NETHER_WART, Blocks::NETHER_WART()); - $this->map1to1Block(Ids::PITCHER_POD, Blocks::PITCHER_CROP()); $this->map1to1Block(Ids::REPEATER, Blocks::REDSTONE_REPEATER()); $this->map1to1Block(Ids::SPRUCE_DOOR, Blocks::SPRUCE_DOOR()); $this->map1to1Block(Ids::SUGAR_CANE, Blocks::SUGARCANE()); @@ -326,6 +325,7 @@ final class ItemSerializerDeserializerRegistrar{ $this->map1to1Item(Ids::PAINTING, Items::PAINTING()); $this->map1to1Item(Ids::PAPER, Items::PAPER()); $this->map1to1Item(Ids::PHANTOM_MEMBRANE, Items::PHANTOM_MEMBRANE()); + $this->map1to1Item(Ids::PITCHER_POD, Items::PITCHER_POD()); $this->map1to1Item(Ids::POISONOUS_POTATO, Items::POISONOUS_POTATO()); $this->map1to1Item(Ids::POPPED_CHORUS_FRUIT, Items::POPPED_CHORUS_FRUIT()); $this->map1to1Item(Ids::PORKCHOP, Items::RAW_PORKCHOP()); diff --git a/src/item/ItemTypeIds.php b/src/item/ItemTypeIds.php index 451d25a59..bf688118b 100644 --- a/src/item/ItemTypeIds.php +++ b/src/item/ItemTypeIds.php @@ -322,8 +322,9 @@ final class ItemTypeIds{ public const RIB_ARMOR_TRIM_SMITHING_TEMPLATE = 20283; public const EYE_ARMOR_TRIM_SMITHING_TEMPLATE = 20284; public const SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = 20285; + public const PITCHER_POD = 20286; - public const FIRST_UNUSED_ITEM_ID = 20286; + public const FIRST_UNUSED_ITEM_ID = 20287; private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID; diff --git a/src/item/PitcherPod.php b/src/item/PitcherPod.php new file mode 100644 index 000000000..be9393515 --- /dev/null +++ b/src/item/PitcherPod.php @@ -0,0 +1,34 @@ +registerBlock("pink_tulip", fn() => Blocks::PINK_TULIP()); $result->registerBlock("piglin_head", fn() => Blocks::MOB_HEAD()->setMobHeadType(MobHeadType::PIGLIN)); $result->registerBlock("pitcher_plant", fn() => Blocks::PITCHER_PLANT()); - $result->registerBlock("pitcher_pod", fn() => Blocks::PITCHER_CROP()); $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)); @@ -1407,6 +1406,7 @@ final class StringToItemParser extends StringToTParser{ $result->register("painting", fn() => Items::PAINTING()); $result->register("paper", fn() => Items::PAPER()); $result->register("phantom_membrane", fn() => Items::PHANTOM_MEMBRANE()); + $result->register("pitcher_pod", fn() => Items::PITCHER_POD()); $result->register("poisonous_potato", fn() => Items::POISONOUS_POTATO()); $result->register("popped_chorus_fruit", fn() => Items::POPPED_CHORUS_FRUIT()); $result->register("porkchop", fn() => Items::RAW_PORKCHOP()); diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index 5f4f60f8e..f9aca9a76 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -240,6 +240,7 @@ use function strtolower; * @method static PaintingItem PAINTING() * @method static Item PAPER() * @method static Item PHANTOM_MEMBRANE() + * @method static PitcherPod PITCHER_POD() * @method static PoisonousPotato POISONOUS_POTATO() * @method static Item POPPED_CHORUS_FRUIT() * @method static Potato POTATO() @@ -503,6 +504,7 @@ final class VanillaItems{ self::register("painting", new PaintingItem(new IID(Ids::PAINTING), "Painting")); self::register("paper", new Item(new IID(Ids::PAPER), "Paper")); self::register("phantom_membrane", new Item(new IID(Ids::PHANTOM_MEMBRANE), "Phantom Membrane")); + self::register("pitcher_pod", new PitcherPod(new IID(Ids::PITCHER_POD), "Pitcher Pod")); self::register("poisonous_potato", new PoisonousPotato(new IID(Ids::POISONOUS_POTATO), "Poisonous Potato")); self::register("popped_chorus_fruit", new Item(new IID(Ids::POPPED_CHORUS_FRUIT), "Popped Chorus Fruit")); self::register("potato", new Potato(new IID(Ids::POTATO), "Potato"));