Added StructureGrowEvent (#4354)

This event is currently fired for tree and bamboo growth. Its intended use is for any plant growth that affects multiple blocks at once.

TODO: We could explore using this for cacti and sugarcane?
This commit is contained in:
Colin
2021-08-25 15:05:30 +02:00
committed by GitHub
parent 6e68e99ec0
commit 4189fbdaef
8 changed files with 66 additions and 11 deletions

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace pocketmine\event\block;
use pocketmine\block\Block;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\world\BlockTransaction;
/**
* Called when structures such as Saplings or Bamboo grow.
* These types of plants tend to change multiple blocks at once upon growing.
*/
class StructureGrowEvent extends BlockEvent implements Cancellable{
use CancellableTrait;
private BlockTransaction $transaction;
public function __construct(Block $block, BlockTransaction $transaction){
parent::__construct($block);
$this->transaction = $transaction;
}
public function getTransaction() : BlockTransaction{
return $this->transaction;
}
}