Implement fortune enchantment (#5757)

This commit is contained in:
ShockedPlot7560
2023-07-17 12:13:45 +02:00
committed by GitHub
parent 8c8794ec71
commit fb6a7d279f
27 changed files with 220 additions and 49 deletions

View File

@ -23,15 +23,15 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\FortuneDropHelper;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
use function mt_rand;
class Carrot extends Crops{
public function getDropsForCompatibleTool(Item $item) : array{
return [
VanillaItems::CARROT()->setCount($this->age >= self::MAX_AGE ? mt_rand(1, 4) : 1)
VanillaItems::CARROT()->setCount($this->age >= self::MAX_AGE ? FortuneDropHelper::binomial($item, 1) : 1)
];
}