diff --git a/src/block/EndPortalFrame.php b/src/block/EndPortalFrame.php index ed5b7743389..1ac0b193548 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; @@ -53,4 +58,18 @@ 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 771154d462b..f1eec55892a 100644 --- a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php +++ b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php @@ -234,6 +234,7 @@ private function register1to1ItemMappings() : void{ $this->map1to1Item(Ids::ENCHANTED_BOOK, Items::ENCHANTED_BOOK()); $this->map1to1Item(Ids::ENCHANTED_GOLDEN_APPLE, Items::ENCHANTED_GOLDEN_APPLE()); $this->map1to1Item(Ids::END_CRYSTAL, Items::END_CRYSTAL()); + $this->map1to1Item(Ids::ENDER_EYE, Items::ENDER_EYE()); $this->map1to1Item(Ids::ENDER_PEARL, Items::ENDER_PEARL()); $this->map1to1Item(Ids::EXPERIENCE_BOTTLE, Items::EXPERIENCE_BOTTLE()); $this->map1to1Item(Ids::EYE_ARMOR_TRIM_SMITHING_TEMPLATE, Items::EYE_ARMOR_TRIM_SMITHING_TEMPLATE()); diff --git a/src/item/EnderEye.php b/src/item/EnderEye.php new file mode 100644 index 00000000000..38e809f430b --- /dev/null +++ b/src/item/EnderEye.php @@ -0,0 +1,28 @@ +register("enchanted_golden_apple", fn() => Items::ENCHANTED_GOLDEN_APPLE()); $result->register("enchanting_bottle", fn() => Items::EXPERIENCE_BOTTLE()); $result->register("end_crystal", fn() => Items::END_CRYSTAL()); + $result->register("ender_eye", fn() => Items::ENDER_EYE()); $result->register("ender_pearl", fn() => Items::ENDER_PEARL()); $result->register("experience_bottle", fn() => Items::EXPERIENCE_BOTTLE()); $result->register("eye_armor_trim_smithing_template", fn() => Items::EYE_ARMOR_TRIM_SMITHING_TEMPLATE()); diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index f76cf369f4e..d2b5f02095a 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -157,6 +157,7 @@ * @method static Item EMERALD() * @method static EnchantedBook ENCHANTED_BOOK() * @method static GoldenAppleEnchanted ENCHANTED_GOLDEN_APPLE() + * @method static EnderEye ENDER_EYE() * @method static EnderPearl ENDER_PEARL() * @method static EndCrystal END_CRYSTAL() * @method static ExperienceBottle EXPERIENCE_BOTTLE() @@ -489,6 +490,7 @@ protected static function setup() : void{ self::register("enchanted_book", fn(IID $id) => new EnchantedBook($id, "Enchanted Book", [EnchantmentTags::ALL])); self::register("enchanted_golden_apple", fn(IID $id) => new GoldenAppleEnchanted($id, "Enchanted Golden Apple")); self::register("end_crystal", fn(IID $id) => new EndCrystal($id, "End Crystal")); + self::register("ender_eye", fn(IID $id) => new EnderEye($id, "Ender Eye")); self::register("ender_pearl", fn(IID $id) => new EnderPearl($id, "Ender Pearl")); self::register("experience_bottle", fn(IID $id) => new ExperienceBottle($id, "Bottle o' Enchanting")); self::register("feather", fn(IID $id) => new Item($id, "Feather")); diff --git a/src/world/sound/EndPortalFrameFillSound.php b/src/world/sound/EndPortalFrameFillSound.php new file mode 100644 index 00000000000..533f5913b59 --- /dev/null +++ b/src/world/sound/EndPortalFrameFillSound.php @@ -0,0 +1,35 @@ +