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

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\BlockDataSerializer;
use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Bamboo as ItemBamboo;
use pocketmine\item\Fertilizer;
use pocketmine\item\Item;
@ -210,6 +211,13 @@ class Bamboo extends Transparent{
foreach($newBlocks as $idx => $newBlock){
$tx->addBlock($this->position->subtract(0, $idx - $growAmount, 0), $newBlock);
}
$ev = new StructureGrowEvent($this, $tx);
$ev->call();
if($ev->isCancelled()){
return false;
}
return $tx->apply();
}