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.
This commit is contained in:
Dylan K. Taylor 2025-05-28 21:00:22 +01:00
parent bf33a625c9
commit baafaed362
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -25,11 +25,12 @@ namespace pocketmine\block;
use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\CropGrowthHelper; use pocketmine\block\utils\CropGrowthHelper;
use pocketmine\block\utils\FortuneDropHelper;
use pocketmine\data\runtime\RuntimeDataDescriber; use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
use pocketmine\math\Facing; use pocketmine\math\Facing;
use function array_rand; use function array_rand;
use function mt_rand;
abstract class Stem extends Crops{ abstract class Stem extends Crops{
protected int $facing = Facing::UP; protected int $facing = Facing::UP;
@ -90,8 +91,10 @@ abstract class Stem extends Crops{
} }
public function getDropsForCompatibleTool(Item $item) : array{ 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 [ return [
$this->asItem()->setCount(mt_rand(0, 2)) $this->asItem()->setCount(FortuneDropHelper::binomial(VanillaItems::AIR(), 0, chance: ($this->age + 1) / 15))
]; ];
} }
} }