From e8d9acb59f5f2148d28caacf3fbe47395478404f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 25 Jun 2019 19:26:18 +0100 Subject: [PATCH] added NoteSound and NoteInstrument enum --- src/pocketmine/world/sound/NoteInstrument.php | 68 +++++++++++++++++++ src/pocketmine/world/sound/NoteSound.php | 47 +++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 src/pocketmine/world/sound/NoteInstrument.php create mode 100644 src/pocketmine/world/sound/NoteSound.php diff --git a/src/pocketmine/world/sound/NoteInstrument.php b/src/pocketmine/world/sound/NoteInstrument.php new file mode 100644 index 000000000..a36c46f14 --- /dev/null +++ b/src/pocketmine/world/sound/NoteInstrument.php @@ -0,0 +1,68 @@ +Enum___construct($name); + $this->magicNumber = $magicNumber; + } + + /** + * @return int + */ + public function getMagicNumber() : int{ + return $this->magicNumber; + } +} diff --git a/src/pocketmine/world/sound/NoteSound.php b/src/pocketmine/world/sound/NoteSound.php new file mode 100644 index 000000000..d81db980d --- /dev/null +++ b/src/pocketmine/world/sound/NoteSound.php @@ -0,0 +1,47 @@ + 255){ + throw new \InvalidArgumentException("Note $note is outside accepted range"); + } + $this->instrument = $instrument; + $this->note = $note; + } + + public function encode(?Vector3 $pos){ + return LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_NOTE, $pos, ($this->instrument->getMagicNumber() << 8) | $this->note); + } +}