diff --git a/src/world/sound/AnvilBreakSound.php b/src/world/sound/AnvilBreakSound.php index 7a75dd415..0e12bdc35 100644 --- a/src/world/sound/AnvilBreakSound.php +++ b/src/world/sound/AnvilBreakSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class AnvilBreakSound extends LevelEventSound{ +class AnvilBreakSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_ANVIL_BREAK; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, 0, $pos); } } diff --git a/src/world/sound/AnvilFallSound.php b/src/world/sound/AnvilFallSound.php index 08aebde71..338b5e0f9 100644 --- a/src/world/sound/AnvilFallSound.php +++ b/src/world/sound/AnvilFallSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class AnvilFallSound extends LevelEventSound{ +class AnvilFallSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_ANVIL_FALL; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_FALL, 0, $pos); } } diff --git a/src/world/sound/AnvilUseSound.php b/src/world/sound/AnvilUseSound.php index 090289a3d..cb9c9841d 100644 --- a/src/world/sound/AnvilUseSound.php +++ b/src/world/sound/AnvilUseSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class AnvilUseSound extends LevelEventSound{ +class AnvilUseSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_ANVIL_USE; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_USE, 0, $pos); } } diff --git a/src/world/sound/BlazeShootSound.php b/src/world/sound/BlazeShootSound.php index 97ac023cc..ed9335e3b 100644 --- a/src/world/sound/BlazeShootSound.php +++ b/src/world/sound/BlazeShootSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class BlazeShootSound extends LevelEventSound{ +class BlazeShootSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, 0, $pos); } } diff --git a/src/world/sound/ClickSound.php b/src/world/sound/ClickSound.php index cec95842d..7fcb02fce 100644 --- a/src/world/sound/ClickSound.php +++ b/src/world/sound/ClickSound.php @@ -23,11 +23,26 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class ClickSound extends LevelEventSound{ +class ClickSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_CLICK; + /** @var float */ + private $pitch; + + public function __construct(float $pitch = 0){ + $this->pitch = $pitch; + } + + /** + * @return float + */ + public function getPitch() : float{ + return $this->pitch; + } + + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_CLICK, (int) ($this->pitch * 1000), $pos); } } diff --git a/src/world/sound/DoorBumpSound.php b/src/world/sound/DoorBumpSound.php index 7ae4e0c92..3d03176f2 100644 --- a/src/world/sound/DoorBumpSound.php +++ b/src/world/sound/DoorBumpSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class DoorBumpSound extends LevelEventSound{ +class DoorBumpSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_DOOR_BUMP; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR_BUMP, 0, $pos); } } diff --git a/src/world/sound/DoorCrashSound.php b/src/world/sound/DoorCrashSound.php index d702e83f5..833d4e9e3 100644 --- a/src/world/sound/DoorCrashSound.php +++ b/src/world/sound/DoorCrashSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class DoorCrashSound extends LevelEventSound{ +class DoorCrashSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_DOOR_CRASH; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR_CRASH, 0, $pos); } } diff --git a/src/world/sound/DoorSound.php b/src/world/sound/DoorSound.php index 779942258..e457e086d 100644 --- a/src/world/sound/DoorSound.php +++ b/src/world/sound/DoorSound.php @@ -23,11 +23,26 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class DoorSound extends LevelEventSound{ +class DoorSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_DOOR; + /** @var float */ + private $pitch; + + public function __construct(float $pitch = 0){ + $this->pitch = $pitch; + } + + /** + * @return float + */ + public function getPitch() : float{ + return $this->pitch; + } + + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR, (int) ($this->pitch * 1000), $pos); } } diff --git a/src/world/sound/EndermanTeleportSound.php b/src/world/sound/EndermanTeleportSound.php index d29787a4e..5f6b2372d 100644 --- a/src/world/sound/EndermanTeleportSound.php +++ b/src/world/sound/EndermanTeleportSound.php @@ -23,14 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class EndermanTeleportSound extends LevelEventSound{ - public function __construct(){ //don't allow specifying a pitch - TODO: remove pitch from sounds that don't have it - parent::__construct(); - } +class EndermanTeleportSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT, 0, $pos); } } diff --git a/src/world/sound/FizzSound.php b/src/world/sound/FizzSound.php index 52d525620..d572d7c71 100644 --- a/src/world/sound/FizzSound.php +++ b/src/world/sound/FizzSound.php @@ -23,11 +23,26 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class FizzSound extends LevelEventSound{ +class FizzSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_FIZZ; + /** @var float */ + private $pitch; + + public function __construct(float $pitch = 0){ + $this->pitch = $pitch; + } + + /** + * @return float + */ + public function getPitch() : float{ + return $this->pitch; + } + + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_FIZZ, (int) ($this->pitch * 1000), $pos); } } diff --git a/src/world/sound/GhastShootSound.php b/src/world/sound/GhastShootSound.php index c376afbf5..0029553ef 100644 --- a/src/world/sound/GhastShootSound.php +++ b/src/world/sound/GhastShootSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class GhastShootSound extends LevelEventSound{ +class GhastShootSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_GHAST_SHOOT; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_GHAST_SHOOT, 0, $pos); } } diff --git a/src/world/sound/GhastSound.php b/src/world/sound/GhastSound.php index 3b29b1d79..484080397 100644 --- a/src/world/sound/GhastSound.php +++ b/src/world/sound/GhastSound.php @@ -23,11 +23,12 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class GhastSound extends LevelEventSound{ +class GhastSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_GHAST; + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_GHAST, 0, $pos); } } diff --git a/src/world/sound/LaunchSound.php b/src/world/sound/LaunchSound.php index 7b02daff6..423289b14 100644 --- a/src/world/sound/LaunchSound.php +++ b/src/world/sound/LaunchSound.php @@ -23,11 +23,26 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class LaunchSound extends LevelEventSound{ +class LaunchSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_SHOOT; + /** @var float */ + private $pitch; + + public function __construct(float $pitch = 0){ + $this->pitch = $pitch; + } + + /** + * @return float + */ + public function getPitch() : float{ + return $this->pitch; + } + + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_SHOOT, (int) ($this->pitch * 1000), $pos); } } diff --git a/src/world/sound/LevelEventSound.php b/src/world/sound/LevelEventSound.php deleted file mode 100644 index 14c0fb7ca..000000000 --- a/src/world/sound/LevelEventSound.php +++ /dev/null @@ -1,54 +0,0 @@ -pitch = $pitch * 1000; - } - - abstract protected function getLevelEventId() : int; - - public function getPitch() : float{ - return $this->pitch / 1000; - } - - public function setPitch(float $pitch) : void{ - $this->pitch = $pitch * 1000; - } - - public function encode(?Vector3 $pos){ - return LevelEventPacket::create($this->getLevelEventId(), (int) $this->pitch, $pos); - } -} diff --git a/src/world/sound/PaintingPlaceSound.php b/src/world/sound/PaintingPlaceSound.php index 3f8792f3d..cf64b248b 100644 --- a/src/world/sound/PaintingPlaceSound.php +++ b/src/world/sound/PaintingPlaceSound.php @@ -23,11 +23,13 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class PaintingPlaceSound extends LevelEventSound{ +class PaintingPlaceSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_ITEMFRAME_PLACE; //item frame and painting have the same sound + public function encode(?Vector3 $pos){ + //item frame and painting have the same sound + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ITEMFRAME_PLACE, 0, $pos); } } diff --git a/src/world/sound/PopSound.php b/src/world/sound/PopSound.php index e74a25352..d38b6473c 100644 --- a/src/world/sound/PopSound.php +++ b/src/world/sound/PopSound.php @@ -23,11 +23,26 @@ declare(strict_types=1); namespace pocketmine\world\sound; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; -class PopSound extends LevelEventSound{ +class PopSound implements Sound{ - protected function getLevelEventId() : int{ - return LevelEventPacket::EVENT_SOUND_POP; + /** @var float */ + private $pitch; + + public function __construct(float $pitch = 0){ + $this->pitch = $pitch; + } + + /** + * @return float + */ + public function getPitch() : float{ + return $this->pitch; + } + + public function encode(?Vector3 $pos){ + return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_POP, (int) ($this->pitch * 1000), $pos); } }