From 5c1e9a35a9baf44883abc9e7dbd4385180170ed3 Mon Sep 17 00:00:00 2001 From: zSALLAZAR <59490940+zSALLAZAR@users.noreply.github.com> Date: Fri, 25 Nov 2022 15:28:41 +0100 Subject: [PATCH] Fix missing sounds when interacting with item frames (#5383) closes #5168 --- src/block/ItemFrame.php | 8 +++++ src/world/sound/ItemFrameAddItemSound.php | 35 ++++++++++++++++++++ src/world/sound/ItemFrameRemoveItemSound.php | 35 ++++++++++++++++++++ src/world/sound/ItemFrameRotateItemSound.php | 35 ++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 src/world/sound/ItemFrameAddItemSound.php create mode 100644 src/world/sound/ItemFrameRemoveItemSound.php create mode 100644 src/world/sound/ItemFrameRotateItemSound.php diff --git a/src/block/ItemFrame.php b/src/block/ItemFrame.php index d71621943..8df62c72f 100644 --- a/src/block/ItemFrame.php +++ b/src/block/ItemFrame.php @@ -31,6 +31,9 @@ use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\BlockTransaction; +use pocketmine\world\sound\ItemFrameAddItemSound; +use pocketmine\world\sound\ItemFrameRemoveItemSound; +use pocketmine\world\sound\ItemFrameRotateItemSound; use function is_infinite; use function is_nan; use function lcg_value; @@ -136,8 +139,12 @@ class ItemFrame extends Flowable{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($this->framedItem !== null){ $this->itemRotation = ($this->itemRotation + 1) % self::ROTATIONS; + + $this->position->getWorld()->addSound($this->position, new ItemFrameRotateItemSound()); }elseif(!$item->isNull()){ $this->framedItem = $item->pop(); + + $this->position->getWorld()->addSound($this->position, new ItemFrameAddItemSound()); }else{ return true; } @@ -154,6 +161,7 @@ class ItemFrame extends Flowable{ $world = $this->position->getWorld(); if(lcg_value() <= $this->itemDropChance){ $world->dropItem($this->position->add(0.5, 0.5, 0.5), clone $this->framedItem); + $world->addSound($this->position, new ItemFrameRemoveItemSound()); } $this->setFramedItem(null); $world->setBlock($this->position, $this); diff --git a/src/world/sound/ItemFrameAddItemSound.php b/src/world/sound/ItemFrameAddItemSound.php new file mode 100644 index 000000000..22e35aead --- /dev/null +++ b/src/world/sound/ItemFrameAddItemSound.php @@ -0,0 +1,35 @@ +