mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +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:
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -125,6 +126,15 @@ class Slab extends Transparent{
|
||||
return [AxisAlignedBB::one()->trim($this->slabType->equals(SlabType::TOP()) ? Facing::DOWN : Facing::UP, 0.5)];
|
||||
}
|
||||
|
||||
public function getSupportType(int $facing) : SupportType{
|
||||
if($this->slabType->equals(SlabType::DOUBLE())){
|
||||
return SupportType::FULL();
|
||||
}elseif(($facing === Facing::UP && $this->slabType->equals(SlabType::TOP())) || ($facing === Facing::DOWN && $this->slabType->equals(SlabType::BOTTOM()))){
|
||||
return SupportType::FULL();
|
||||
}
|
||||
return SupportType::NONE();
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [$this->asItem()->setCount($this->slabType->equals(SlabType::DOUBLE()) ? 2 : 1)];
|
||||
}
|
||||
|
Reference in New Issue
Block a user