diff --git a/src/block/BaseSign.php b/src/block/BaseSign.php index b01157343..5a7df4663 100644 --- a/src/block/BaseSign.php +++ b/src/block/BaseSign.php @@ -103,27 +103,10 @@ abstract class BaseSign extends Transparent implements WoodMaterial{ return SupportType::NONE; } - /** - * @deprecated - */ abstract protected function getSupportingFace() : int; - /** - * @return int[] - */ - protected function getSupportingFaceOptions() : array{ - return [$this->getSupportingFace()]; - } - public function onNearbyBlockChange() : void{ - $foundSupport = false; - foreach($this->getSupportingFaceOptions() as $face){ - if($this->getSide($face)->getTypeId() !== BlockTypeIds::AIR){ - $foundSupport = true; - break; - } - } - if(!$foundSupport){ + if($this->getSide($this->getSupportingFace())->getTypeId() !== BlockTypeIds::AIR){ $this->position->getWorld()->useBreakOn($this->position); } } diff --git a/src/block/WallHangingSign.php b/src/block/WallHangingSign.php index c167036b1..2332f8e4f 100644 --- a/src/block/WallHangingSign.php +++ b/src/block/WallHangingSign.php @@ -27,6 +27,7 @@ use pocketmine\block\utils\HorizontalFacing; use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\item\Item; use pocketmine\math\Axis; +use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; @@ -39,12 +40,13 @@ final class WallHangingSign extends BaseSign implements HorizontalFacing{ return Facing::rotateY($this->facing, clockwise: true); } - protected function getSupportingFaceOptions() : array{ - //wall hanging signs can be supported from either end of the post - return [ - Facing::rotateY($this->facing, clockwise: true), - Facing::rotateY($this->facing, clockwise: false) - ]; + public function onNearbyBlockChange() : void{ + //NOOP - disable default self-destruct behaviour + } + + protected function recalculateCollisionBoxes() : array{ + //only the cross bar is collidable + return [AxisAlignedBB::one()->trim(Facing::DOWN, 7 / 8)->squash(Facing::axis($this->facing), 3 / 4)]; } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{