Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ender eye placement in portal frame #5913

Open
wants to merge 6 commits into
base: minor-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/block/EndPortalFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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){
ShockedPlot7560 marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
$world = $this->getPosition()->getWorld();
$world->setBlock($this->getPosition(), $this->setEye(true));
$world->addSound($this->getPosition(), new EndPortalFillSound());
$item->pop();

ShockedPlot7560 marked this conversation as resolved.
Show resolved Hide resolved
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/item/ItemTypeIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

declare(strict_types=1);

namespace pocketmine\world\sound;

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

class EndPortalFillSound implements Sound{
ShockedPlot7560 marked this conversation as resolved.
Show resolved Hide resolved

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