diff --git a/src/pocketmine/block/SnowLayer.php b/src/pocketmine/block/SnowLayer.php index ab8168e82..adb0aa7fb 100644 --- a/src/pocketmine/block/SnowLayer.php +++ b/src/pocketmine/block/SnowLayer.php @@ -42,7 +42,7 @@ class SnowLayer extends Flowable{ } public function canBeReplaced() : bool{ - return true; + return $this->meta < 7; //8 snow layers } public function getHardness() : float{ @@ -57,9 +57,15 @@ class SnowLayer extends Flowable{ return TieredTool::TIER_WOODEN; } + private function canBeSupportedBy(Block $b) : bool{ + return $b->isSolid() or ($b->getId() === $this->getId() and $b->getDamage() === 7); + } + public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ - if($blockReplace->getSide(Vector3::SIDE_DOWN)->isSolid()){ - //TODO: fix placement + if($blockReplace->getId() === $this->getId() and $blockReplace->getDamage() < 7){ + $this->setDamage($blockReplace->getDamage() + 1); + } + if($this->canBeSupportedBy($blockReplace->getSide(Vector3::SIDE_DOWN))){ $this->getLevel()->setBlock($blockReplace, $this, true); return true; @@ -69,7 +75,7 @@ class SnowLayer extends Flowable{ } public function onNearbyBlockChange() : void{ - if(!$this->getSide(Vector3::SIDE_DOWN)->isSolid()){ + if(!$this->canBeSupportedBy($this->getSide(Vector3::SIDE_DOWN))){ $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false, false); } }