22declare(strict_types=1);
26use pocketmine\block\utils\AmethystTrait;
27use pocketmine\block\utils\AnyFacingTrait;
29use pocketmine\block\utils\SupportType;
45 public const STAGE_SMALL_BUD = 0;
46 public const STAGE_MEDIUM_BUD = 1;
47 public const STAGE_LARGE_BUD = 2;
48 public const STAGE_CLUSTER = 3;
50 private int $stage = self::STAGE_CLUSTER;
53 $w->boundedIntAuto(self::STAGE_SMALL_BUD, self::STAGE_CLUSTER, $this->stage);
56 public function getStage() : int{ return $this->stage; }
58 public function setStage(
int $stage) : self{
59 if($stage < self::STAGE_SMALL_BUD || $stage > self::STAGE_CLUSTER){
60 throw new \InvalidArgumentException(
"Size must be in range " . self::STAGE_SMALL_BUD .
" ... " . self::STAGE_CLUSTER);
62 $this->stage = $stage;
67 return match($this->stage){
68 self::STAGE_SMALL_BUD => 1,
69 self::STAGE_MEDIUM_BUD => 2,
70 self::STAGE_LARGE_BUD => 4,
71 self::STAGE_CLUSTER => 5,
77 $myAxis =
Facing::axis($this->facing);
79 $box = AxisAlignedBB::one();
80 foreach([Axis::Y, Axis::Z, Axis::X] as $axis){
81 if($axis === $myAxis){
84 $box->squash($axis, $this->stage === self::STAGE_SMALL_BUD ? 4 / 16 : 3 / 16);
86 $box->trim($this->facing, 1 - ($this->stage === self::STAGE_CLUSTER ? 7 / 16 : ($this->stage + 3) / 16));
91 private function canBeSupportedAt(Block $block,
int $facing) : bool{
92 return $block->getAdjacentSupportType($facing) === SupportType::FULL;
96 return SupportType::NONE;
100 if(!$this->canBeSupportedAt($blockReplace,
Facing::opposite($face))){
104 $this->facing = $face;
105 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
109 if(!$this->canBeSupportedAt($this,
Facing::opposite($this->facing))){
110 $this->position->getWorld()->useBreakOn($this->position);
119 if($this->stage === self::STAGE_CLUSTER){
120 return [VanillaItems::AMETHYST_SHARD()->setCount(FortuneDropHelper::weighted($item, min: 4, maxBase: 4))];
127 if($this->stage === self::STAGE_CLUSTER){
128 return [VanillaItems::AMETHYST_SHARD()->setCount(FortuneDropHelper::weighted($item, min: 2, maxBase: 2))];
describeBlockItemState(RuntimeDataDescriber $w)
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
getSupportType(int $facing)
recalculateCollisionBoxes()
getDropsForCompatibleTool(Item $item)
getDropsForIncompatibleTool(Item $item)