getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::FARMLAND; } protected function recalculateCollisionBoxes() : array{ $widthTrim = $this->age === 0 ? 5 : 3; $heightTrim = $this->age === 0 ? 13 : 11; return [ AxisAlignedBB::one() ->trim(Facing::UP, $heightTrim / 16) ->squash(Axis::X, $widthTrim / 16) ->squash(Axis::Z, $widthTrim / 16) ->extend(Facing::DOWN, 1 / 16) //presumably this is to correct for farmland being 15/16 of a block tall ]; } private function grow(?Player $player) : bool{ if($this->age > self::MAX_AGE){ return false; } if($this->age === self::MAX_AGE){ $up = $this->getSide(Facing::UP); if($up->getTypeId() !== BlockTypeIds::AIR){ return false; } $tx = new BlockTransaction($this->position->getWorld()); $tx->addBlock($this->position, VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(false)); $tx->addBlock($this->position->up(), VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(true)); $ev = new StructureGrowEvent($this, $tx, $player); $ev->call(); return !$ev->isCancelled() && $tx->apply(); } return BlockEventHelper::grow($this, (clone $this)->setAge($this->age + 1), $player); } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($item instanceof Fertilizer && $this->grow($player)){ $item->pop(); return true; } return false; } public function ticksRandomly() : bool{ return true; } public function onRandomTick() : void{ if(CropGrowthHelper::canGrow($this)){ $this->grow(null); } } public function asItem() : Item{ return VanillaItems::PITCHER_POD(); } }