Skip to content

Commit e134c0c

Browse files
committed
1 parent 97a26fd commit e134c0c

File tree

7 files changed

+39
-1
lines changed

7 files changed

+39
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Additions
5353
> https://github.com/pmmp/PocketMine-MP/pull/5861
5454
> https://github.com/pmmp/PocketMine-MP/pull/5864
5555
> https://github.com/pmmp/PocketMine-MP/pull/5906
56+
> https://github.com/pmmp/PocketMine-MP/pull/5913
5657
5758

5859
## What is this?

src/block/EndPortalFrame.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@
2525

2626
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
2727
use pocketmine\data\runtime\RuntimeDataDescriber;
28+
use pocketmine\item\Item;
29+
use pocketmine\item\ItemTypeIds;
2830
use pocketmine\math\AxisAlignedBB;
2931
use pocketmine\math\Facing;
32+
use pocketmine\math\Vector3;
33+
use pocketmine\player\Player;
34+
use pocketmine\world\sound\EndPortalFrameFillSound;
3035

3136
class EndPortalFrame extends Opaque{
3237
use FacesOppositePlacingPlayerTrait;
@@ -56,4 +61,17 @@ public function getLightLevel() : int{
5661
protected function recalculateCollisionBoxes() : array{
5762
return [AxisAlignedBB::one()->trim(Facing::UP, 3 / 16)];
5863
}
64+
65+
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
66+
if($this->eye || $item->getTypeId() !== ItemTypeIds::ENDER_EYE){
67+
return false;
68+
}
69+
$world = $this->position->getWorld();
70+
$world->setBlock($this->position, $this->setEye(true));
71+
$world->addSound($this->position, new EndPortalFrameFillSound());
72+
$item->pop();
73+
//TODO: portal spawn logic
74+
75+
return true;
76+
}
5977
}

src/data/bedrock/item/ItemSerializerDeserializerRegistrar.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ private function register1to1ItemMappings() : void{
231231
$this->map1to1Item(Ids::EMERALD, Items::EMERALD());
232232
$this->map1to1Item(Ids::ENCHANTED_BOOK, Items::ENCHANTED_BOOK());
233233
$this->map1to1Item(Ids::ENCHANTED_GOLDEN_APPLE, Items::ENCHANTED_GOLDEN_APPLE());
234+
$this->map1to1Item(Ids::ENDER_EYE, Items::ENDER_EYE());
234235
$this->map1to1Item(Ids::END_CRYSTAL, Items::END_CRYSTAL());
235236
$this->map1to1Item(Ids::ENDER_PEARL, Items::ENDER_PEARL());
236237
$this->map1to1Item(Ids::EXPERIENCE_BOTTLE, Items::EXPERIENCE_BOTTLE());

src/item/ItemTypeIds.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,9 @@ private function __construct(){
329329
public const FIREWORK_ROCKET = 20290;
330330
public const FIREWORK_STAR = 20291;
331331
public const RECOVERY_COMPASS = 20292;
332+
public const ENDER_EYE = 20293;
332333

333-
public const FIRST_UNUSED_ITEM_ID = 20293;
334+
public const FIRST_UNUSED_ITEM_ID = 20294;
334335

335336
private static int $nextDynamicId = self::FIRST_UNUSED_ITEM_ID;
336337

src/item/StringToItemParser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ private static function registerItems(self $result) : void{
13191319
$result->register("enchanted_book", fn() => Items::ENCHANTED_BOOK());
13201320
$result->register("enchanted_golden_apple", fn() => Items::ENCHANTED_GOLDEN_APPLE());
13211321
$result->register("enchanting_bottle", fn() => Items::EXPERIENCE_BOTTLE());
1322+
$result->register("ender_eye", fn() => Items::ENDER_EYE());
13221323
$result->register("end_crystal", fn() => Items::END_CRYSTAL());
13231324
$result->register("ender_pearl", fn() => Items::ENDER_PEARL());
13241325
$result->register("experience_bottle", fn() => Items::EXPERIENCE_BOTTLE());

src/item/VanillaItems.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
* @method static Item EMERALD()
157157
* @method static EnchantedBook ENCHANTED_BOOK()
158158
* @method static GoldenAppleEnchanted ENCHANTED_GOLDEN_APPLE()
159+
* @method static Item ENDER_EYE()
159160
* @method static EnderPearl ENDER_PEARL()
160161
* @method static EndCrystal END_CRYSTAL()
161162
* @method static ExperienceBottle EXPERIENCE_BOTTLE()
@@ -460,6 +461,7 @@ protected static function setup() : void{
460461
self::register("emerald", new Item(new IID(Ids::EMERALD), "Emerald"));
461462
self::register("enchanted_book", new EnchantedBook(new IID(Ids::ENCHANTED_BOOK), "Enchanted Book", [EnchantmentTags::ALL]));
462463
self::register("enchanted_golden_apple", new GoldenAppleEnchanted(new IID(Ids::ENCHANTED_GOLDEN_APPLE), "Enchanted Golden Apple"));
464+
self::register("ender_eye", new Item(new IID(Ids::ENDER_EYE), "Ender Eye"));
463465
self::register("end_crystal", new EndCrystal(new IID(Ids::END_CRYSTAL), "End Crystal"));
464466
self::register("ender_pearl", new EnderPearl(new IID(Ids::ENDER_PEARL), "Ender Pearl"));
465467
self::register("experience_bottle", new ExperienceBottle(new IID(Ids::EXPERIENCE_BOTTLE), "Bottle o' Enchanting"));
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace pocketmine\world\sound;
4+
5+
use pocketmine\math\Vector3;
6+
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
7+
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
8+
9+
class EndPortalFrameFillSound implements Sound{
10+
11+
public function encode(Vector3 $pos) : array{
12+
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_END_PORTAL_FRAME_FILL, $pos, false)];
13+
}
14+
}

0 commit comments

Comments
 (0)