38 use HorizontalFacingTrait;
40 abstract protected function isHead() : bool;
42 private function canBeSupportedBy(
Block $block,
bool $head) :
bool{
46 $block->
getTypeId() === BlockTypeIds::CLAY ||
56 $this->position->getWorld()->useBreakOn($this->position);
61 $block = $blockReplace->getSide(
Facing::DOWN);
62 if(!$this->canBeSupportedBy($block,
true)){
66 $this->facing = Facing::opposite($player->getHorizontalFacing());
68 if($block instanceof BaseBigDripleaf){
69 $this->facing = $block->facing;
70 $tx->
addBlock($block->position, VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($this->facing));
72 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
76 if($item instanceof
Fertilizer && $this->grow($player)){
83 private function seekToHead() : ?BaseBigDripleaf{
88 while(($next = $this->getSide(Facing::UP, $step)) instanceof BaseBigDripleaf){
97 private function grow(?Player $player) : bool{
98 $head = $this->seekToHead();
102 $pos = $head->position;
104 $world = $pos->getWorld();
106 !$world->isInWorld($up->getFloorX(), $up->getFloorY(), $up->getFloorZ()) ||
107 $world->getBlock($up)->getTypeId() !== BlockTypeIds::AIR
112 $tx =
new BlockTransaction($world);
114 $tx->
addBlock($pos, VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($head->facing));
115 $tx->
addBlock($up, VanillaBlocks::BIG_DRIPLEAF_HEAD()->setFacing($head->facing));
117 $ev =
new StructureGrowEvent($head, $tx, $player);
120 if(!$ev->isCancelled()){
135 return SupportType::NONE;
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)