Apparently hanging signs are self supporting

This commit is contained in:
Dylan K. Taylor 2025-08-25 02:15:24 +01:00
parent f04c458e54
commit 4a2c7dc684
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 9 additions and 24 deletions

View File

@ -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);
}
}

View File

@ -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{