From e134c0c8d3169a707bfb17ee0219700b58dfdda8 Mon Sep 17 00:00:00 2001 From: Joshy3282 Date: Wed, 2 Oct 2024 13:12:28 -0500 Subject: [PATCH] add https://github.com/pmmp/PocketMine-MP/pull/5913 --- README.md | 1 + src/block/EndPortalFrame.php | 18 ++++++++++++++++++ .../ItemSerializerDeserializerRegistrar.php | 1 + src/item/ItemTypeIds.php | 3 ++- src/item/StringToItemParser.php | 1 + src/item/VanillaItems.php | 2 ++ src/world/sound/EndPortalFrameFillSound.php | 14 ++++++++++++++ 7 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/world/sound/EndPortalFrameFillSound.php diff --git a/README.md b/README.md index b3e911dbe54..595bdb75576 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Additions > https://github.com/pmmp/PocketMine-MP/pull/5861 > https://github.com/pmmp/PocketMine-MP/pull/5864 > https://github.com/pmmp/PocketMine-MP/pull/5906 +> https://github.com/pmmp/PocketMine-MP/pull/5913 ## What is this? diff --git a/src/block/EndPortalFrame.php b/src/block/EndPortalFrame.php index 612cf3723cf..62a9294d6cf 100644 --- a/src/block/EndPortalFrame.php +++ b/src/block/EndPortalFrame.php @@ -25,8 +25,13 @@ use pocketmine\block\utils\FacesOppositePlacingPlayerTrait; use pocketmine\data\runtime\RuntimeDataDescriber; +use pocketmine\item\Item; +use pocketmine\item\ItemTypeIds; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; +use pocketmine\math\Vector3; +use pocketmine\player\Player; +use pocketmine\world\sound\EndPortalFrameFillSound; class EndPortalFrame extends Opaque{ use FacesOppositePlacingPlayerTrait; @@ -56,4 +61,17 @@ public function getLightLevel() : int{ protected function recalculateCollisionBoxes() : array{ return [AxisAlignedBB::one()->trim(Facing::UP, 3 / 16)]; } + + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ + if($this->eye || $item->getTypeId() !== ItemTypeIds::ENDER_EYE){ + return false; + } + $world = $this->position->getWorld(); + $world->setBlock($this->position, $this->setEye(true)); + $world->addSound($this->position, new EndPortalFrameFillSound()); + $item->pop(); + //TODO: portal spawn logic + + return true; + } } diff --git a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php index e058f0fe15a..133e9948175 100644 --- a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php +++ b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php @@ -231,6 +231,7 @@ private function register1to1ItemMappings() : void{ $this->map1to1Item(Ids::EMERALD, Items::EMERALD()); $this->map1to1Item(Ids::ENCHANTED_BOOK, Items::ENCHANTED_BOOK()); $this->map1to1Item(Ids::ENCHANTED_GOLDEN_APPLE, Items::ENCHANTED_GOLDEN_APPLE()); + $this->map1to1Item(Ids::ENDER_EYE, Items::ENDER_EYE()); $this->map1to1Item(Ids::END_CRYSTAL, Items::END_CRYSTAL()); $this->map1to1Item(Ids::ENDER_PEARL, Items::ENDER_PEARL()); $this->map1to1Item(Ids::EXPERIENCE_BOTTLE, Items::EXPERIENCE_BOTTLE()); diff --git a/src/item/ItemTypeIds.php b/src/item/ItemTypeIds.php index 61c82929df6..03e75e4da93 100644 --- a/src/item/ItemTypeIds.php +++ b/src/item/ItemTypeIds.php @@ -329,8 +329,9 @@ private function __construct(){ public const FIREWORK_ROCKET = 20290; public const FIREWORK_STAR = 20291; public const RECOVERY_COMPASS = 20292; + public const ENDER_EYE = 20293; - public const FIRST_UNUSED_ITEM_ID = 20293; + public const FIRST_UNUSED_ITEM_ID = 20294; private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID; diff --git a/src/item/StringToItemParser.php b/src/item/StringToItemParser.php index 37b67f11bcf..1d56cad7775 100644 --- a/src/item/StringToItemParser.php +++ b/src/item/StringToItemParser.php @@ -1319,6 +1319,7 @@ private static function registerItems(self $result) : void{ $result->register("enchanted_book", fn() => Items::ENCHANTED_BOOK()); $result->register("enchanted_golden_apple", fn() => Items::ENCHANTED_GOLDEN_APPLE()); $result->register("enchanting_bottle", fn() => Items::EXPERIENCE_BOTTLE()); + $result->register("ender_eye", fn() => Items::ENDER_EYE()); $result->register("end_crystal", fn() => Items::END_CRYSTAL()); $result->register("ender_pearl", fn() => Items::ENDER_PEARL()); $result->register("experience_bottle", fn() => Items::EXPERIENCE_BOTTLE()); diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index 0d19861dc38..3ded6dd73d9 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -156,6 +156,7 @@ * @method static Item EMERALD() * @method static EnchantedBook ENCHANTED_BOOK() * @method static GoldenAppleEnchanted ENCHANTED_GOLDEN_APPLE() + * @method static Item ENDER_EYE() * @method static EnderPearl ENDER_PEARL() * @method static EndCrystal END_CRYSTAL() * @method static ExperienceBottle EXPERIENCE_BOTTLE() @@ -460,6 +461,7 @@ protected static function setup() : void{ self::register("emerald", new Item(new IID(Ids::EMERALD), "Emerald")); self::register("enchanted_book", new EnchantedBook(new IID(Ids::ENCHANTED_BOOK), "Enchanted Book", [EnchantmentTags::ALL])); self::register("enchanted_golden_apple", new GoldenAppleEnchanted(new IID(Ids::ENCHANTED_GOLDEN_APPLE), "Enchanted Golden Apple")); + self::register("ender_eye", new Item(new IID(Ids::ENDER_EYE), "Ender Eye")); self::register("end_crystal", new EndCrystal(new IID(Ids::END_CRYSTAL), "End Crystal")); self::register("ender_pearl", new EnderPearl(new IID(Ids::ENDER_PEARL), "Ender Pearl")); self::register("experience_bottle", new ExperienceBottle(new IID(Ids::EXPERIENCE_BOTTLE), "Bottle o' Enchanting")); diff --git a/src/world/sound/EndPortalFrameFillSound.php b/src/world/sound/EndPortalFrameFillSound.php new file mode 100644 index 00000000000..9c40f464642 --- /dev/null +++ b/src/world/sound/EndPortalFrameFillSound.php @@ -0,0 +1,14 @@ +