Implemented modifiers for crop growth speed

closes #6070

there are some unresolved questions about the growth speed of beetroots, pitcher plants and torchflower crops, but that's a topic for another commit.
this change also doesn't account for the light levels.
This commit is contained in:
Dylan K. Taylor
2023-11-02 15:16:11 +00:00
parent 1e4a1565bb
commit 109673382d
6 changed files with 115 additions and 10 deletions

View File

@ -25,6 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\AgeableTrait;
use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\CropGrowthHelper;
use pocketmine\block\utils\StaticSupportTrait;
use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Fertilizer;
@ -35,7 +36,6 @@ use pocketmine\math\Facing;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
use function mt_rand;
final class PitcherCrop extends Flowable{
use AgeableTrait;
@ -97,8 +97,7 @@ final class PitcherCrop extends Flowable{
}
public function onRandomTick() : void{
//TODO: the growth speed is influenced by farmland and nearby crops
if(mt_rand(0, 2) === 0){
if(CropGrowthHelper::canGrow($this)){
$this->grow(null);
}
}