37 use HorizontalFacingTrait;
39 abstract protected function isHead() : bool;
41 private function canBeSupportedBy(
Block $block,
bool $head) :
bool{
45 $block->
getTypeId() === BlockTypeIds::CLAY ||
55 $this->position->getWorld()->useBreakOn($this->position);
60 $block = $blockReplace->getSide(
Facing::DOWN);
61 if(!$this->canBeSupportedBy($block,
true)){
65 $this->facing = Facing::opposite($player->getHorizontalFacing());
67 if($block instanceof BaseBigDripleaf){
68 $this->facing = $block->facing;
69 $tx->
addBlock($block->position, VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($this->facing));
71 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
75 if($item instanceof
Fertilizer && $this->grow($player)){
82 private function seekToHead() : ?BaseBigDripleaf{
87 while(($next = $this->getSide(Facing::UP, $step)) instanceof BaseBigDripleaf){
96 private function grow(?Player $player) : bool{
97 $head = $this->seekToHead();
101 $pos = $head->position;
103 $world = $pos->getWorld();
105 !$world->isInWorld($up->getFloorX(), $up->getFloorY(), $up->getFloorZ()) ||
106 $world->getBlock($up)->getTypeId() !== BlockTypeIds::AIR
111 $tx =
new BlockTransaction($world);
113 $tx->
addBlock($pos, VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($head->facing));
114 $tx->
addBlock($up, VanillaBlocks::BIG_DRIPLEAF_HEAD()->setFacing($head->facing));
116 $ev =
new StructureGrowEvent($head, $tx, $player);
119 if(!$ev->isCancelled()){
134 return SupportType::NONE;
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)