mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +00:00
SnowLayer: fixed layer stacking, closes #2775
This commit is contained in:
parent
9d26a224a2
commit
3f2455f090
@ -42,7 +42,7 @@ class SnowLayer extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function canBeReplaced() : bool{
|
public function canBeReplaced() : bool{
|
||||||
return true;
|
return $this->meta < 7; //8 snow layers
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHardness() : float{
|
public function getHardness() : float{
|
||||||
@ -57,9 +57,15 @@ class SnowLayer extends Flowable{
|
|||||||
return TieredTool::TIER_WOODEN;
|
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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
if($blockReplace->getSide(Vector3::SIDE_DOWN)->isSolid()){
|
if($blockReplace->getId() === $this->getId() and $blockReplace->getDamage() < 7){
|
||||||
//TODO: fix placement
|
$this->setDamage($blockReplace->getDamage() + 1);
|
||||||
|
}
|
||||||
|
if($this->canBeSupportedBy($blockReplace->getSide(Vector3::SIDE_DOWN))){
|
||||||
$this->getLevel()->setBlock($blockReplace, $this, true);
|
$this->getLevel()->setBlock($blockReplace, $this, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -69,7 +75,7 @@ class SnowLayer extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
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);
|
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user