22declare(strict_types=1);
26use pocketmine\block\utils\SupportType;
34 public const MIN_COUNT = 1;
35 public const MAX_COUNT = 4;
37 protected int $count = self::MIN_COUNT;
38 protected bool $underwater =
false;
41 $w->boundedIntAuto(self::MIN_COUNT, self::MAX_COUNT, $this->count);
42 $w->bool($this->underwater);
45 public function getCount() : int{ return $this->count; }
49 if($count < self::MIN_COUNT || $count > self::MAX_COUNT){
50 throw new \InvalidArgumentException(
"Count must be in range " . self::MIN_COUNT .
" ... " . self::MAX_COUNT);
52 $this->count = $count;
56 public function isUnderwater() : bool{ return $this->underwater; }
60 $this->underwater = $underwater;
69 return $this->underwater ? ($this->count + 1) * 3 : 0;
77 return SupportType::NONE;
82 return ($blockReplace instanceof
SeaPickle && $blockReplace->count < self::MAX_COUNT) || parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock);
86 $this->underwater = false;
87 if($blockReplace instanceof
SeaPickle && $blockReplace->count < self::MAX_COUNT){
88 $this->count = $blockReplace->count + 1;
91 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
96 return parent::onInteract($item, $face, $clickVector, $player, $returnedItems);
100 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)