count = ($stateMeta & 0x03) + 1; $this->underwater = ($stateMeta & BlockLegacyMetadata::SEA_PICKLE_FLAG_NOT_UNDERWATER) === 0; } protected function writeStateToMeta() : int{ return ($this->count - 1) | ($this->underwater ? 0 : BlockLegacyMetadata::SEA_PICKLE_FLAG_NOT_UNDERWATER); } public function getStateBitmask() : int{ return 0b111; } public function getCount() : int{ return $this->count; } /** @return $this */ public function setCount(int $count) : self{ if($count < self::MIN_COUNT || $count > self::MAX_COUNT){ throw new \InvalidArgumentException("Count must be in range " . self::MIN_COUNT . " ... " . self::MAX_COUNT); } $this->count = $count; return $this; } public function isUnderwater() : bool{ return $this->underwater; } /** @return $this */ public function setUnderwater(bool $underwater) : self{ $this->underwater = $underwater; return $this; } public function isSolid() : bool{ return false; } public function getLightLevel() : int{ return $this->underwater ? ($this->count + 1) * 3 : 0; } /** * @return AxisAlignedBB[] */ protected function recalculateCollisionBoxes() : array{ return []; } public function getSupportType(int $facing) : SupportType{ return SupportType::NONE(); } public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{ //TODO: proper placement logic (needs a supporting face below) return ($blockReplace instanceof SeaPickle && $blockReplace->count < self::MAX_COUNT) || parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock); } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->underwater = false; //TODO: implement this once we have new water logic in place if($blockReplace instanceof SeaPickle && $blockReplace->count < self::MAX_COUNT){ $this->count = $blockReplace->count + 1; } return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ //TODO: bonemeal logic (requires coral) return parent::onInteract($item, $face, $clickVector, $player); } public function getDropsForCompatibleTool(Item $item) : array{ return [$this->asItem()->setCount($this->count)]; } }