Skip to content

Commit

Permalink
add pmmp#5913
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshy3282 committed Oct 2, 2024
1 parent 97a26fd commit e134c0c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
18 changes: 18 additions & 0 deletions src/block/EndPortalFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/item/ItemTypeIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/item/StringToItemParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions src/item/VanillaItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"));
Expand Down
14 changes: 14 additions & 0 deletions src/world/sound/EndPortalFrameFillSound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace pocketmine\world\sound;

use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;

class EndPortalFrameFillSound implements Sound{

public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BLOCK_END_PORTAL_FRAME_FILL, $pos, false)];
}
}

0 comments on commit e134c0c

Please sign in to comment.