22declare(strict_types=1);
 
   24namespace pocketmine\block\utils;
 
   30use 
function mt_getrandmax;
 
   47    public static function weighted(
Item $usedItem, 
int $min, 
int $maxBase) : int{
 
   49            throw new \InvalidArgumentException(
"Maximum drop amount must be greater than or equal to minimum drop amount");
 
   52        $fortuneLevel = $usedItem->getEnchantmentLevel(VanillaEnchantments::FORTUNE());
 
   55            $fortuneLevel > 0 && mt_rand() / mt_getrandmax() > 2 / ($fortuneLevel + 2) ?
 
   56                $maxBase * ($fortuneLevel + 1) :
 
 
   73    public static function binomial(
Item $usedItem, 
int $min, 
int $minRolls = 3, 
float $chance = 4 / 7) : int{
 
   77        $rolls = $minRolls + $fortuneLevel;
 
   78        for($i = 0; $i < $rolls; ++$i){
 
   79            if(mt_rand() / mt_getrandmax() < $chance){
 
 
   95    public static function discrete(
Item $usedItem, 
int $min, 
int $maxBase) : int{
 
   97            throw new \InvalidArgumentException(
"Minimum base drop amount must be less than or equal to maximum base drop amount");
 
  100        $max = $maxBase + $usedItem->getEnchantmentLevel(VanillaEnchantments::FORTUNE());
 
  101        return mt_rand($min, $max);
 
 
  115        return mt_rand(1, max(1, $divisorBase - ($fortuneLevel * $divisorSubtractPerLevel))) === 1;
 
 
  126        $chance = min(1, $chanceBase + ($fortuneLevel * $addedChancePerLevel));
 
  127        return mt_rand() / mt_getrandmax() < $chance;
 
 
 
static weighted(Item $usedItem, int $min, int $maxBase)
 
static discrete(Item $usedItem, int $min, int $maxBase)
 
static binomial(Item $usedItem, int $min, int $minRolls=3, float $chance=4/7)
 
static bonusChanceDivisor(Item $usedItem, int $divisorBase, int $divisorSubtractPerLevel)
 
static bonusChanceFixed(Item $usedItem, float $chanceBase, float $addedChancePerLevel)