PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
pocketmine\block\utils\FortuneDropHelper Class Reference
+ Collaboration diagram for pocketmine\block\utils\FortuneDropHelper:

Static Public Member Functions

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)
 
static discrete (Item $usedItem, int $min, int $maxBase)
 
static weighted (Item $usedItem, int $min, int $maxBase)
 

Detailed Description

Definition at line 33 of file FortuneDropHelper.php.

Member Function Documentation

◆ binomial()

static pocketmine\block\utils\FortuneDropHelper::binomial ( Item $usedItem,
int $min,
int $minRolls = 3,
float $chance = 4 / 7 )
static

Increases the drop amount according to a binomial distribution. The function will roll maxBase+level times, and add 1 if a random number between 0-1 is less than the given probability. Each level of fortune adds one extra roll.

As many as maxBase+level items can be dropped. This applies even if the fortune level is 0.

Parameters
float$chanceThe chance of adding 1 to the amount for each roll, must be in the range 0-1
int$minMinimum amount
int$minRollsNumber of rolls if fortune level is 0, added to fortune level to calculate total rolls
Returns
int the number of items to drop

Definition at line 73 of file FortuneDropHelper.php.

◆ bonusChanceDivisor()

static pocketmine\block\utils\FortuneDropHelper::bonusChanceDivisor ( Item $usedItem,
int $divisorBase,
int $divisorSubtractPerLevel )
static

Calculates a chance of getting an extra bonus drop by reducing the chance divisor by a given amount per fortune level.

Parameters
int$divisorBaseThe number to divide 1 by to get the chance, as if the fortune level was 0
int$divisorSubtractPerLevelThe amount to subtract from the divisor for each level of fortune
Returns
bool whether the bonus drop should be added

Definition at line 113 of file FortuneDropHelper.php.

◆ bonusChanceFixed()

static pocketmine\block\utils\FortuneDropHelper::bonusChanceFixed ( Item $usedItem,
float $chanceBase,
float $addedChancePerLevel )
static

Calculates a chance of getting an extra bonus drop by increasing the chance by a fixed amount per fortune level.

Parameters
float$chanceBaseThe base chance of getting a bonus drop, as if the fortune level was 0
float$addedChancePerLevelThe amount to add to the chance for each level of fortune

Definition at line 124 of file FortuneDropHelper.php.

◆ discrete()

static pocketmine\block\utils\FortuneDropHelper::discrete ( Item $usedItem,
int $min,
int $maxBase )
static

Adds the fortune level to the base max and picks a random number between the minimim and adjusted maximum. Each amount in the range has an equal chance of being picked.

Parameters
int$maxBaseMaximum base amount, as if the fortune level was 0
Returns
int the number of items to drop

Definition at line 95 of file FortuneDropHelper.php.

◆ weighted()

static pocketmine\block\utils\FortuneDropHelper::weighted ( Item $usedItem,
int $min,
int $maxBase )
static

If a random number between 0-1 is greater than 2/(level+2), this multiplies the max drop amount by level+1, and picks a random amount between the minimum and multiplied maximum. Each level of fortune increases the chance of fortune activation, and also increases the maximum drop limit when activated.

Otherwise, returns a random amount of the item between the minimum and original maximum.

Parameters
Item$usedItemThe item used to break the block
int$minMinimum amount
int$maxBaseMaximum amount, as if fortune level was 0
Returns
int the number of items to drop

Definition at line 47 of file FortuneDropHelper.php.


The documentation for this class was generated from the following file: