Class NoteBlockMusic
You can write small text scripts for Minecraft note blocks without needing to use any redstone or building to make your music. This class is independent of XSound.
- Version:
- 3.0.0
- Author:
- Crypto Morin
- See Also:
-
Instrument
Note
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An instruction is any musical movement or section that can be a restatement and might have a fermata.static class
A sequence is a restatement collection of multiple otherNoteBlockMusic.Sequence
s andNoteBlockMusic.Sound
that itself might be a part of anotherNoteBlockMusic.Sequence
static class
An instruction that produces a sonud which consists of aInstrument
and aNote
withNote.Tone
, but without duration or -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<Void>
Plays a music from a file.static org.bukkit.Note.Tone
getNoteTone
(char ch) Gets a note tone from a character.static XSound
getSoundFromInstrument
(org.bukkit.Instrument instrument) static float
noteToPitch
(org.bukkit.Note note) static NoteBlockMusic.Sequence
parseInstructions
(CharSequence script) static org.bukkit.Note
Parses a MinecraftNote
with itsNote.Tone
With the format: <tone>[pitch][octave]static CompletableFuture<Void>
This is a very special and unique method.static CompletableFuture<Void>
testMusic
(org.bukkit.entity.Player player) A pre-written music script to test withplayMusic(Player, Supplier, String)
If you made a cool script using this let me know, I'll put it here.
-
Method Details
-
getSoundFromInstrument
-
getNoteTone
Gets a note tone from a character. Can't be optimized further using an array since switch statement here can be optimized by JIT even more.The character paseed to this method is assumed to be uppercase, otherwise it needs to be
ch & 0x5f
manually.https://minecraft.wiki/w/Note_Block#Notes
- Parameters:
ch
- the character of the note tone.- Returns:
- the note tone or null if not found.
- Since:
- 3.0.0
-
testMusic
A pre-written music script to test withplayMusic(Player, Supplier, String)
If you made a cool script using this let me know, I'll put it here. You can still give me the script and I'll put it on the Spigot page.- Parameters:
player
- the player to send the notes to.- Returns:
- the async task handling the notes.
- Since:
- 1.0.0
-
fromFile
public static CompletableFuture<Void> fromFile(@Nonnull org.bukkit.entity.Player player, @Nonnull Supplier<org.bukkit.Location> location, @Nonnull Path path) Plays a music from a file. This file can have YAML comments (#) and empty lines.- Parameters:
player
- the player to play the music to.location
- the location to play the notes to.path
- the path of the file to read the music notes from.- Returns:
- the async task handling the file operations and music parsers.
- Since:
- 1.0.0
- See Also:
-
playMusic
public static CompletableFuture<Void> playMusic(@Nonnull org.bukkit.entity.Player player, @Nonnull Supplier<org.bukkit.Location> location, @Nullable String script) This is a very special and unique method. This method allows you to write your own Minecraft music without needing to use redstones and note blocks.We'll take a whole thread for the music for blocking requests. Format:
Instrument, Tone, Repeat (optional), Repeating Delay (optional, required if Repeat is used) [Next Delay]
Both delays are in milliseconds.
Also you can use segments (segment) to repeat a segment multiple times.Example
Shortcuts:
BD,G 20 BD,G 20 BD,G -> BD,G,3,20
(BD,G,3,20 BG,E,5,10),1000,2 1000 BA,A Translated: Play BASS_DRUM with tone G 3 times every 20 ticks.
Play BASS_GUITAR with tone E 5 times every 10 ticks.
Play those ^ again two times with 1 second delay between repeats.
Wait 1000ms.
Play BANJO with tone A once.Note Tones
Available Note Tones: G, A, B, C, D, E, F (Idk why G is the first one)
Note.Tone
You can also use sharp or flat tones by using '#' for sharp and '_' for flat e.g. B_ C#
Octave numbers 1 and 2 can be used. C1, C#1, B_1, D_2Instruments
Available Instruments: Basically the first letter of every instrument. E.g.
BD -> BASS_DRUM
You can also use their full name.Instrument
CompletableFuture
Warning: Do not use blocking methods such as join() or get() You may use cancel() or the then... methods.
- Parameters:
player
- in order to play the note we need a player instance. Any player.location
- the location to play this note to.script
- the music script.- Returns:
- the async task processing the script.
- Since:
- 1.0.0
- See Also:
-
parseInstructions
-
parseNote
Parses a MinecraftNote
with itsNote.Tone
With the format: <tone>[pitch][octave]Available Note Tones: G, A, B, C, D, E, F (Idk why G is the first one)
Note.Tone
You can also use sharp or flat tones by using '#' for sharp and '_' for flat e.g. B_ C#
Octave numbers 1 and 2 can be used. C1, C#1, B_1, D_2
Pitch Octave- Returns:
- a note with a tone.
- Since:
- 3.0.0
-
noteToPitch
-