layers - 1; } public function readStateFromMeta(int $meta) : void{ $this->layers = BlockDataValidator::readBoundedInt("layers", $meta + 1, 1, 8); } public function getStateBitmask() : int{ return 0b111; } public function getName() : string{ return "Snow Layer"; } public function canBeReplaced() : bool{ return $this->layers < 8; } public function getHardness() : float{ return 0.1; } public function getToolType() : int{ return BlockToolType::TYPE_SHOVEL; } public function getToolHarvestLevel() : int{ return TieredTool::TIER_WOODEN; } protected function recalculateBoundingBox() : ?AxisAlignedBB{ //TODO: this zero-height BB is intended to stay in lockstep with a MCPE bug return AxisAlignedBB::one()->trim(Facing::UP, $this->layers >= 4 ? 0.5 : 1); } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($blockReplace instanceof SnowLayer){ if($blockReplace->layers >= 8){ return false; } $this->layers = $blockReplace->layers + 1; } if($blockReplace->getSide(Facing::DOWN)->isSolid()){ //TODO: fix placement return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } return false; } public function ticksRandomly() : bool{ return true; } public function onRandomTick() : void{ if($this->level->getBlockLightAt($this->x, $this->y, $this->z) >= 12){ $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false); } } public function tickFalling() : ?Block{ return null; } public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::SNOWBALL, 0, max(1, (int) floor($this->layers / 2))) ]; } public function isAffectedBySilkTouch() : bool{ return false; } }