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