From 8d289ab01d419f97f2946b7779b1c3a43516f596 Mon Sep 17 00:00:00 2001 From: NTT1906 Date: Fri, 28 Jan 2022 00:21:16 +0700 Subject: [PATCH] Bell: fixed collision boxes closes #4745 --- src/block/Bell.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/block/Bell.php b/src/block/Bell.php index 2b33610b6..7c836ceeb 100644 --- a/src/block/Bell.php +++ b/src/block/Bell.php @@ -29,6 +29,7 @@ use pocketmine\block\utils\BlockDataSerializer; use pocketmine\block\utils\HorizontalFacingTrait; use pocketmine\block\utils\InvalidBlockStateException; use pocketmine\item\Item; +use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; @@ -78,6 +79,28 @@ final class Bell extends Transparent{ return 0b1111; } + protected function recalculateCollisionBoxes() : array{ + if($this->attachmentType->equals(BellAttachmentType::FLOOR())){ + return [ + AxisAlignedBB::one()->squash(Facing::axis($this->facing), 1 / 4)->trim(Facing::UP, 3 / 16) + ]; + } + if($this->attachmentType->equals(BellAttachmentType::CEILING())){ + return [ + AxisAlignedBB::one()->contract(1 / 4, 0, 1 / 4)->trim(Facing::DOWN, 1 / 4) + ]; + } + + $box = AxisAlignedBB::one() + ->squash(Facing::axis(Facing::rotateY($this->facing, true)), 1 / 4) + ->trim(Facing::UP, 1 / 16) + ->trim(Facing::DOWN, 1 / 4); + + return [ + $this->attachmentType->equals(BellAttachmentType::ONE_WALL()) ? $box->trim($this->facing, 3 / 16) : $box + ]; + } + public function getAttachmentType() : BellAttachmentType{ return $this->attachmentType; } /** @return $this */