mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Block: introduce logic for face support types (#4886)
fixes #4856 fixes #458 fixes #4529 fixes #3299 Added API method Block::getSupportType(Facing) : SupportType Added SupportType enum fixes torch, lantern, door etc. placement on slabs and upside-down stairs
This commit is contained in:
@ -96,7 +96,7 @@ class Lever extends Flowable{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$blockClicked->isSolid()){
|
||||
if(!$this->canBeSupportedBy($blockClicked, $face)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -120,7 +120,8 @@ class Lever extends Flowable{
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->getSide(Facing::opposite($this->facing->getFacing()))->isSolid()){
|
||||
$facing = $this->facing->getFacing();
|
||||
if(!$this->canBeSupportedBy($this->getSide(Facing::opposite($facing)), $facing)){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
@ -135,5 +136,9 @@ class Lever extends Flowable{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function canBeSupportedBy(Block $block, int $face) : bool{
|
||||
return $block->getSupportType($face)->hasCenterSupport();
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
Reference in New Issue
Block a user