mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-26 21:18:43 +00:00
CocoaBlock: deduplicate attachment condition checking
This commit is contained in:
parent
9ab3c57789
commit
82bb83211f
@ -85,8 +85,12 @@ class CocoaBlock extends Transparent{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function canAttachTo(Block $block) : bool{
|
||||||
|
return $block instanceof Wood && $block->getTreeType()->equals(TreeType::JUNGLE());
|
||||||
|
}
|
||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
if(Facing::axis($face) !== Axis::Y and $blockClicked instanceof Wood and $blockClicked->getTreeType()->equals(TreeType::JUNGLE())){
|
if(Facing::axis($face) !== Axis::Y and $this->canAttachTo($blockClicked)){
|
||||||
$this->facing = $face;
|
$this->facing = $face;
|
||||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}
|
}
|
||||||
@ -108,8 +112,7 @@ class CocoaBlock extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
$side = $this->getSide(Facing::opposite($this->facing));
|
if(!$this->canAttachTo($this->getSide(Facing::opposite($this->facing)))){
|
||||||
if(!($side instanceof Wood) or !$side->getTreeType()->equals(TreeType::JUNGLE())){
|
|
||||||
$this->pos->getWorld()->useBreakOn($this->pos);
|
$this->pos->getWorld()->useBreakOn($this->pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user