From baafaed3621a11ec3034f747ccff37a499175c6f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 28 May 2025 21:00:22 +0100 Subject: [PATCH] Stem drops seeds according to binomial distribution fixes #6709 we really need a better way to reverse-engineer the chance parameter for these as the wiki just gives a probability table, which is quite tiresome to extract patterns from. --- src/block/Stem.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/block/Stem.php b/src/block/Stem.php index 2ac95aa3f1..2b6f2150c5 100644 --- a/src/block/Stem.php +++ b/src/block/Stem.php @@ -25,11 +25,12 @@ namespace pocketmine\block; use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\CropGrowthHelper; +use pocketmine\block\utils\FortuneDropHelper; use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\item\Item; +use pocketmine\item\VanillaItems; use pocketmine\math\Facing; use function array_rand; -use function mt_rand; abstract class Stem extends Crops{ protected int $facing = Facing::UP; @@ -90,8 +91,10 @@ abstract class Stem extends Crops{ } public function getDropsForCompatibleTool(Item $item) : array{ + //TODO: bit annoying we have to pass an Item instance here + //this should not be affected by Fortune, but still follows a binomial distribution return [ - $this->asItem()->setCount(mt_rand(0, 2)) + $this->asItem()->setCount(FortuneDropHelper::binomial(VanillaItems::AIR(), 0, chance: ($this->age + 1) / 15)) ]; } }