Remove ItemFactory usage from Bucket

This commit is contained in:
Dylan K. Taylor 2022-06-05 21:19:38 +01:00
parent d2613039ed
commit 02568bb049
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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()){