From 02568bb04947f0eee8a4ef43975e694371e5124a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 5 Jun 2022 21:19:38 +0100 Subject: [PATCH] Remove ItemFactory usage from Bucket --- src/item/Bucket.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/item/Bucket.php b/src/item/Bucket.php index 3d6c818a1..749dd8a0b 100644 --- a/src/item/Bucket.php +++ b/src/item/Bucket.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\item; use pocketmine\block\Block; +use pocketmine\block\BlockTypeIds; use pocketmine\block\Liquid; use pocketmine\block\VanillaBlocks; use pocketmine\event\player\PlayerBucketFillEvent; @@ -42,7 +43,15 @@ class Bucket extends Item{ $stack = clone $this; $stack->pop(); - $resultItem = ItemFactory::getInstance()->get(ItemIds::BUCKET, $blockClicked->getFlowingForm()->getId()); + $resultItem = match($blockClicked->getTypeId()){ + BlockTypeIds::LAVA => VanillaItems::LAVA_BUCKET(), + BlockTypeIds::WATER => VanillaItems::WATER_BUCKET(), + default => null + }; + if($resultItem === null){ + return ItemUseResult::FAIL(); + } + $ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem); $ev->call(); if(!$ev->isCancelled()){