BlockGrowEvent: add player information for bonemeal usage (#5596)

this is in line with StructureGrowEvent, which also has a similar API.
This commit is contained in:
Hugo_
2023-05-08 18:38:07 +02:00
committed by GitHub
parent 6f0eb019d2
commit d834266635
5 changed files with 26 additions and 8 deletions

View File

@ -23,9 +23,27 @@ declare(strict_types=1);
namespace pocketmine\event\block;
use pocketmine\block\Block;
use pocketmine\player\Player;
/**
* Called when plants or crops grow.
*/
class BlockGrowEvent extends BaseBlockChangeEvent{
public function __construct(
Block $block,
Block $newState,
private ?Player $player = null,
){
parent::__construct($block, $newState);
}
/**
* It returns the player which grows the crop.
* It returns null when the crop grows by itself.
*/
public function getPlayer() : ?Player{
return $this->player;
}
}