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;
78 return SupportType::NONE;
83 return ($blockReplace instanceof
SeaPickle && $blockReplace->count < self::MAX_COUNT) || parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock);
87 $this->underwater = false;
88 if($blockReplace instanceof
SeaPickle && $blockReplace->count < self::MAX_COUNT){
89 $this->count = $blockReplace->count + 1;
92 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
97 return parent::onInteract($item, $face, $clickVector, $player, $returnedItems);
101 return [$this->asItem()->setCount($this->count)];
getSupportType(Facing $facing)
getDropsForCompatibleTool(Item $item)
onInteract(Item $item, Facing $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
canBePlacedAt(Block $blockReplace, Vector3 $clickVector, Facing $face, bool $isClickedBlock)
setUnderwater(bool $underwater)
describeBlockOnlyState(RuntimeDataDescriber $w)
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, Facing $face, Vector3 $clickVector, ?Player $player=null)
recalculateCollisionBoxes()