From 81edb1bed494639f512427bd97cf481e6f777fd8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 16 Jul 2022 20:00:43 +0100 Subject: [PATCH] GlassBottle: implement filling using API changes from 4afd3dcabfa6b9c645ab8b15fade1e37f889482f closes #4827 --- src/item/GlassBottle.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/item/GlassBottle.php b/src/item/GlassBottle.php index ca59fd2b3..bda6d132e 100644 --- a/src/item/GlassBottle.php +++ b/src/item/GlassBottle.php @@ -23,6 +23,21 @@ declare(strict_types=1); namespace pocketmine\item; +use pocketmine\block\Block; +use pocketmine\block\BlockTypeIds; +use pocketmine\math\Vector3; +use pocketmine\player\Player; + class GlassBottle extends Item{ + public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{ + if($blockClicked->getTypeId() === BlockTypeIds::WATER){ + $this->pop(); + $returnedItems[] = VanillaItems::POTION()->setType(PotionType::WATER()); + + return ItemUseResult::SUCCESS(); + } + + return ItemUseResult::NONE(); + } }