boundedIntAuto(self::STAGE_SMALL_BUD, self::STAGE_CLUSTER, $this->stage); } public function getStage() : int{ return $this->stage; } public function setStage(int $stage) : self{ if($stage < self::STAGE_SMALL_BUD || $stage > self::STAGE_CLUSTER){ throw new \InvalidArgumentException("Size must be in range " . self::STAGE_SMALL_BUD . " ... " . self::STAGE_CLUSTER); } $this->stage = $stage; return $this; } public function getLightLevel() : int{ return match($this->stage){ self::STAGE_SMALL_BUD => 1, self::STAGE_MEDIUM_BUD => 2, self::STAGE_LARGE_BUD => 4, self::STAGE_CLUSTER => 5, default => throw new AssumptionFailedError("Invalid stage $this->stage"), }; } protected function recalculateCollisionBoxes() : array{ $myAxis = Facing::axis($this->facing); $box = AxisAlignedBB::one(); foreach([Axis::Y, Axis::Z, Axis::X] as $axis){ if($axis === $myAxis){ continue; } $box->squash($axis, $this->stage === self::STAGE_SMALL_BUD ? 4 / 16 : 3 / 16); } $box->trim($this->facing, 1 - ($this->stage === self::STAGE_CLUSTER ? 7 / 16 : ($this->stage + 3) / 16)); return [$box]; } private function canBeSupportedAt(Block $block, int $facing) : bool{ return $block->getAdjacentSupportType($facing) === SupportType::FULL; } public function getSupportType(int $facing) : SupportType{ return SupportType::NONE; } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if(!$this->canBeSupportedAt($blockReplace, Facing::opposite($face))){ return false; } $this->facing = $face; return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } public function onNearbyBlockChange() : void{ if(!$this->canBeSupportedAt($this, Facing::opposite($this->facing))){ $this->position->getWorld()->useBreakOn($this->position); } } public function isAffectedBySilkTouch() : bool{ return true; } public function getDropsForCompatibleTool(Item $item) : array{ if($this->stage === self::STAGE_CLUSTER){ return [VanillaItems::AMETHYST_SHARD()->setCount(FortuneDropHelper::weighted($item, min: 4, maxBase: 4))]; } return []; } public function getDropsForIncompatibleTool(Item $item) : array{ if($this->stage === self::STAGE_CLUSTER){ return [VanillaItems::AMETHYST_SHARD()->setCount(FortuneDropHelper::weighted($item, min: 2, maxBase: 2))]; } return []; } }