So I was fooling around on my piano today and I discovered the keys to play the music that plays when you get a hammer item in Super Smash Bros (Brawl). So... of course... I wanted to be able to play it using the note block sounds. I just created a few methods, one to loop to play the notes so I wouldn't have to copy-and-paste the note-playing code lines and the other to actually play the sound. Here is the code: Code:java //Made it protected because it is an unnecessary method, that is, most likely only used in this classprotected void playNoteSound(Player player, Note note, int times){ for(int i = 0; i < times; i++){ player.playNote(player.getLocation(), Instrument.PIANO, note); }} //Actually playing the soundpublic void playHammerMusic(Player player){ Note g = new Note(5, Note.Tone.G, false); Note b = new Note(6, Note.Tone.B, false); Note d = new Note(6, Note.Tone.D, false); //The music this.playNoteSound(player, g, 5); this.playNoteSound(player, b, 1); this.playNoteSound(player, g, 1); this.playNoteSound(player, b, 1); this.playNoteSound(player, g, 1); this.playNoteSound(player, b, 5); this.playNoteSound(player, d, 1); this.playNoteSound(player, b, 1); this.playNoteSound(player, d, 1); this.playNoteSound(player, b, 1); //And repeat... this.playNoteSound(player, g, 5); this.playNoteSound(player, b, 1); this.playNoteSound(player, g, 1); this.playNoteSound(player, b, 1); this.playNoteSound(player, g, 1); this.playNoteSound(player, b, 5); this.playNoteSound(player, d, 1); this.playNoteSound(player, b, 1); this.playNoteSound(player, d, 1); this.playNoteSound(player, b, 1);} I have not actually tested how this will function in-game; it may need to have a few tick delay in between each note playing. If someone is willing to test this and see how it will function, feel free!
chasechocolate A simple way would be to make a new thread (Async task), and use Thread.sleep() in that.