isSource()){ $stack = clone $this; $stack->pop(); $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()){ $player->getWorld()->setBlock($blockClicked->getPosition(), VanillaBlocks::AIR()); $player->getWorld()->addSound($blockClicked->getPosition()->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound()); $this->pop(); $returnedItems[] = $ev->getItem(); return ItemUseResult::SUCCESS(); } return ItemUseResult::FAIL(); } return ItemUseResult::NONE(); } }