39 use StaticSupportTrait;
49 private readonly
int $nyliumTypeId,
50 private readonly TreeType $treeType
52 parent::__construct($idInfo, $name, $typeInfo);
55 private function canBeSupportedAt(
Block $block) : bool{
59 $supportBlock->
hasTypeTag(BlockTypeTags::DIRT) ||
60 $supportBlock->hasTypeTag(BlockTypeTags::MUD) ||
61 $supportBlock->hasTypeTag(BlockTypeTags::NYLIUM) ||
62 $supportBlock->getTypeId() === BlockTypeIds::SOUL_SOIL;
68 if($this->getSide(Facing::DOWN)->getTypeId() === $this->nyliumTypeId && ($player ===
null || !$player->hasFiniteResources() || mt_rand(1, 100) <= 40)){
76 private function grow(?
Player $player) : void{
77 $random = new Random(mt_rand());
78 $tree = TreeFactory::get($random, $this->treeType);
79 $transaction = $tree?->getBlockTransaction($this->position->getWorld(), $this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ(), $random);
80 if($transaction ===
null){
84 $ev =
new StructureGrowEvent($this, $transaction, $player);
86 if(!$ev->isCancelled()){
87 $transaction->apply();