From 76f2c60cb653748f23de97ec7dc5ec9f7340840a Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 Date: Tue, 18 Jul 2023 18:26:44 +0200 Subject: [PATCH 1/5] implement ender_eye placement in end_portal_frame --- src/block/EndPortalFrame.php | 17 +++++++++ .../ItemSerializerDeserializerRegistrar.php | 1 + src/item/ItemTypeIds.php | 3 +- src/item/StringToItemParser.php | 1 + src/item/VanillaItems.php | 2 ++ src/world/sound/EndPortalFillSound.php | 35 +++++++++++++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/world/sound/EndPortalFillSound.php diff --git a/src/block/EndPortalFrame.php b/src/block/EndPortalFrame.php index 08c903f117e..f697af724a9 100644 --- a/src/block/EndPortalFrame.php +++ b/src/block/EndPortalFrame.php @@ -26,8 +26,13 @@ use pocketmine\block\utils\FacesOppositePlacingPlayerTrait; use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\data\runtime\RuntimeDataDescriber; +use pocketmine\item\Item; +use pocketmine\item\VanillaItems; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; +use pocketmine\math\Vector3; +use pocketmine\player\Player; +use pocketmine\world\sound\EndPortalFillSound; class EndPortalFrame extends Opaque{ use FacesOppositePlacingPlayerTrait; @@ -58,4 +63,16 @@ 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(!$item->equals(VanillaItems::ENDER_EYE()) || $this->eye){ + return false; + } + $world = $this->getPosition()->getWorld(); + $world->setBlock($this->getPosition(), $this->setEye(true)); + $world->addSound($this->getPosition(), new EndPortalFillSound()); + $item->pop(); + + return true; + } } diff --git a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php index 6f557ddb138..03340c6d79b 100644 --- a/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php +++ b/src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php @@ -224,6 +224,7 @@ private function register1to1ItemMappings() : void{ $this->map1to1Item(Ids::EGG, Items::EGG()); $this->map1to1Item(Ids::EMERALD, Items::EMERALD()); $this->map1to1Item(Ids::ENCHANTED_GOLDEN_APPLE, Items::ENCHANTED_GOLDEN_APPLE()); + $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::FEATHER, Items::FEATHER()); diff --git a/src/item/ItemTypeIds.php b/src/item/ItemTypeIds.php index f37426c56a3..b090f0e2b0a 100644 --- a/src/item/ItemTypeIds.php +++ b/src/item/ItemTypeIds.php @@ -303,8 +303,9 @@ private function __construct(){ public const MANGROVE_BOAT = 20264; public const GLOW_BERRIES = 20265; public const CHERRY_SIGN = 20266; + public const ENDER_EYE = 20267; - public const FIRST_UNUSED_ITEM_ID = 20267; + public const FIRST_UNUSED_ITEM_ID = 20268; private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID; diff --git a/src/item/StringToItemParser.php b/src/item/StringToItemParser.php index ea9923c2194..60d8c362aa2 100644 --- a/src/item/StringToItemParser.php +++ b/src/item/StringToItemParser.php @@ -1278,6 +1278,7 @@ private static function registerItems(self $result) : void{ $result->register("emerald", fn() => Items::EMERALD()); $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("ender_pearl", fn() => Items::ENDER_PEARL()); $result->register("experience_bottle", fn() => Items::EXPERIENCE_BOTTLE()); $result->register("eye_drops", fn() => Items::MEDICINE()->setType(MedicineType::EYE_DROPS())); diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index b7c32ebc111..17ecec6dfae 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -152,6 +152,7 @@ * @method static Egg EGG() * @method static Item EMERALD() * @method static GoldenAppleEnchanted ENCHANTED_GOLDEN_APPLE() + * @method static Item ENDER_EYE() * @method static EnderPearl ENDER_PEARL() * @method static ExperienceBottle EXPERIENCE_BOTTLE() * @method static Item FEATHER() @@ -430,6 +431,7 @@ protected static function setup() : void{ self::register("egg", new Egg(new IID(Ids::EGG), "Egg")); self::register("emerald", new Item(new IID(Ids::EMERALD), "Emerald")); 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("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")); self::register("feather", new Item(new IID(Ids::FEATHER), "Feather")); diff --git a/src/world/sound/EndPortalFillSound.php b/src/world/sound/EndPortalFillSound.php new file mode 100644 index 00000000000..9857b902f6e --- /dev/null +++ b/src/world/sound/EndPortalFillSound.php @@ -0,0 +1,35 @@ + Date: Sun, 30 Jul 2023 14:43:00 +0200 Subject: [PATCH 2/5] change conditions --- src/block/EndPortalFrame.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/block/EndPortalFrame.php b/src/block/EndPortalFrame.php index f697af724a9..e72a75a3087 100644 --- a/src/block/EndPortalFrame.php +++ b/src/block/EndPortalFrame.php @@ -27,7 +27,7 @@ use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\item\Item; -use pocketmine\item\VanillaItems; +use pocketmine\item\ItemTypeIds; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\Vector3; @@ -65,7 +65,7 @@ protected function recalculateCollisionBoxes() : array{ } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ - if(!$item->equals(VanillaItems::ENDER_EYE()) || $this->eye){ + if($this->eye || $item->getTypeId() !== ItemTypeIds::ENDER_EYE){ return false; } $world = $this->getPosition()->getWorld(); From d198d749629acfea40965bda8d0b48215bbb7ff7 Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 Date: Mon, 31 Jul 2023 17:28:23 +0200 Subject: [PATCH 3/5] rename sound + add todo --- src/block/EndPortalFrame.php | 6 ++++-- .../{EndPortalFillSound.php => EndPortalFrameFillSound.php} | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) rename src/world/sound/{EndPortalFillSound.php => EndPortalFrameFillSound.php} (95%) diff --git a/src/block/EndPortalFrame.php b/src/block/EndPortalFrame.php index e72a75a3087..e6581745384 100644 --- a/src/block/EndPortalFrame.php +++ b/src/block/EndPortalFrame.php @@ -32,7 +32,7 @@ use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; -use pocketmine\world\sound\EndPortalFillSound; +use pocketmine\world\sound\EndPortalFrameFillSound; class EndPortalFrame extends Opaque{ use FacesOppositePlacingPlayerTrait; @@ -70,9 +70,11 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player } $world = $this->getPosition()->getWorld(); $world->setBlock($this->getPosition(), $this->setEye(true)); - $world->addSound($this->getPosition(), new EndPortalFillSound()); + $world->addSound($this->getPosition(), new EndPortalFrameFillSound()); $item->pop(); + //TODO: portal spawn logic + return true; } } diff --git a/src/world/sound/EndPortalFillSound.php b/src/world/sound/EndPortalFrameFillSound.php similarity index 95% rename from src/world/sound/EndPortalFillSound.php rename to src/world/sound/EndPortalFrameFillSound.php index 9857b902f6e..533f5913b59 100644 --- a/src/world/sound/EndPortalFillSound.php +++ b/src/world/sound/EndPortalFrameFillSound.php @@ -27,7 +27,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; -class EndPortalFillSound implements Sound{ +class EndPortalFrameFillSound implements Sound{ public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_END_PORTAL_FRAME_FILL, $pos, false)]; From 35d775ed16e2e5d8f6af6f8ceb6cb59b2b31857c Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 Date: Mon, 7 Aug 2023 18:39:21 +0200 Subject: [PATCH 4/5] remove getPosition() --- src/block/EndPortalFrame.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/block/EndPortalFrame.php b/src/block/EndPortalFrame.php index e6581745384..ce386ee5530 100644 --- a/src/block/EndPortalFrame.php +++ b/src/block/EndPortalFrame.php @@ -68,9 +68,9 @@ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player if($this->eye || $item->getTypeId() !== ItemTypeIds::ENDER_EYE){ return false; } - $world = $this->getPosition()->getWorld(); - $world->setBlock($this->getPosition(), $this->setEye(true)); - $world->addSound($this->getPosition(), new EndPortalFrameFillSound()); + $world = $this->position->getWorld(); + $world->setBlock($this->position, $this->setEye(true)); + $world->addSound($this->position, new EndPortalFrameFillSound()); $item->pop(); //TODO: portal spawn logic From 08b6d9956cf00c7ddedbecccac643cff4f140786 Mon Sep 17 00:00:00 2001 From: "Dylan T." Date: Thu, 14 Nov 2024 18:03:07 +0000 Subject: [PATCH 5/5] REEEEEEEE --- src/item/ItemTypeIds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item/ItemTypeIds.php b/src/item/ItemTypeIds.php index b72a7b05185..2e3b306fa63 100644 --- a/src/item/ItemTypeIds.php +++ b/src/item/ItemTypeIds.php @@ -325,7 +325,7 @@ private function __construct(){ public const PITCHER_POD = 20286; public const NAME_TAG = 20287; public const GOAT_HORN = 20288; - public const ENDER_EYE = 20289; + public const ENDER_EYE = 20289; public const FIRST_UNUSED_ITEM_ID = 20290;