mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-19 15:35:52 +00:00
Sugarcane: fixed support conditions (#5052)
This commit is contained in:
parent
2f4a9469b6
commit
8fa81242d6
@ -98,7 +98,7 @@ class Sugarcane extends Flowable{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->isTransparent() && !$down->isSameType($this)){
|
||||
if(!$this->isValidSupport($down)){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
@ -122,9 +122,10 @@ class Sugarcane extends Flowable{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->isSameType($this)){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}elseif($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::SAND || $down->getId() === BlockLegacyIds::PODZOL){
|
||||
}elseif($this->isValidSupport($down)){
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
if($down->getSide($side) instanceof Water){
|
||||
$sideBlock = $down->getSide($side);
|
||||
if($sideBlock instanceof Water || $sideBlock instanceof FrostedIce){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
}
|
||||
@ -132,4 +133,15 @@ class Sugarcane extends Flowable{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isValidSupport(Block $block) : bool{
|
||||
$id = $block->getId();
|
||||
//TODO: rooted dirt, moss block
|
||||
return $block->isSameType($this)
|
||||
|| $id === BlockLegacyIds::GRASS
|
||||
|| $id === BlockLegacyIds::DIRT
|
||||
|| $id === BlockLegacyIds::PODZOL
|
||||
|| $id === BlockLegacyIds::MYCELIUM
|
||||
|| $id === BlockLegacyIds::SAND;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user