mushroomBlockType = MushroomBlockType::ALL_CAP(); parent::__construct($idInfo, $name, $breakInfo); } protected function writeStateToMeta() : int{ return MushroomBlockTypeIdMap::getInstance()->toId($this->mushroomBlockType); } protected function writeStateToItemMeta() : int{ //these blocks always drop as all-cap, but may exist in other forms in the inventory (particularly creative) return BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_CAP; } public function readStateFromData(int $id, int $stateMeta) : void{ $type = MushroomBlockTypeIdMap::getInstance()->fromId($stateMeta); if($type === null){ throw new InvalidBlockStateException("No such mushroom variant $stateMeta"); } $this->mushroomBlockType = $type; } public function getStateBitmask() : int{ return 0b1111; } public function getMushroomBlockType() : MushroomBlockType{ return $this->mushroomBlockType; } /** @return $this */ public function setMushroomBlockType(MushroomBlockType $mushroomBlockType) : self{ $this->mushroomBlockType = $mushroomBlockType; return $this; } public function getDropsForCompatibleTool(Item $item) : array{ return [ VanillaBlocks::RED_MUSHROOM()->asItem()->setCount(mt_rand(0, 2)) ]; } public function isAffectedBySilkTouch() : bool{ return true; } }