22declare(strict_types=1);
26use pocketmine\block\utils\SupportType;
35 public const MIN_COUNT = 1;
36 public const MAX_COUNT = 4;
38 protected int $count = self::MIN_COUNT;
39 protected bool $underwater =
false;
42 $w->boundedIntAuto(self::MIN_COUNT, self::MAX_COUNT, $this->count);
43 $w->bool($this->underwater);
46 public function getCount() : int{ return $this->count; }
50 if($count < self::MIN_COUNT || $count > self::MAX_COUNT){
51 throw new \InvalidArgumentException(
"Count must be in range " . self::MIN_COUNT .
" ... " . self::MAX_COUNT);
53 $this->count = $count;
57 public function isUnderwater() : bool{ return $this->underwater; }
61 $this->underwater = $underwater;
70 return $this->underwater ? ($this->count + 1) * 3 : 0;
81 return SupportType::NONE;
86 return ($blockReplace instanceof
SeaPickle && $blockReplace->count < self::MAX_COUNT) || parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock);
90 $this->underwater = false;
91 if($blockReplace instanceof
SeaPickle && $blockReplace->count < self::MAX_COUNT){
92 $this->count = $blockReplace->count + 1;
95 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
100 return parent::onInteract($item, $face, $clickVector, $player, $returnedItems);
104 return [$this->asItem()->setCount($this->count)];
getDropsForCompatibleTool(Item $item)
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
setUnderwater(bool $underwater)
getSupportType(int $facing)
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
describeBlockOnlyState(RuntimeDataDescriber $w)
recalculateCollisionBoxes()
canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock)