45 public const MAX_AGE = 1;
49 $this->describeAge($w);
60 ->trim(Facing::UP, 11 / 16)
61 ->squash(Axis::X, 3 / 16)
62 ->squash(Axis::Z, 3 / 16)
63 ->extend(Facing::DOWN, 1 / 16)
67 private function grow(?
Player $player) : bool{
68 if($this->age >= self::MAX_AGE){
72 $bottom = $this->top ? $this->getSide(Facing::DOWN) : $this;
73 $top = $this->top ? $this : $this->getSide(Facing::UP);
74 if($top->getTypeId() !== BlockTypeIds::AIR && !$top->hasSameTypeId($this)){
78 $newState = (clone $this)->setAge($this->age + 1);
80 $tx =
new BlockTransaction($this->position->getWorld());
81 $tx->addBlock($bottom->position, (clone $newState)->setTop(
false));
82 $tx->addBlock($top->position, (clone $newState)->setTop(
true));
84 $ev =
new StructureGrowEvent($bottom, $tx, $player);
87 return !$ev->isCancelled() && $tx->apply();
92 if($item instanceof
Fertilizer && $this->grow($player)){
101 return $this->age < self::MAX_AGE && !$this->top;