/** * Creates a new note for a sharp tone, such as A-sharp. * * @param octave The octave where the note is in. Has to be 0 - 2. * @param tone The tone within the octave. If the octave is 2 the note has * to be F#. * @return The new note. */ public static Note sharp(int octave, Tone tone) { return new Note(octave, tone, true); }
@Override public void setRawNote(byte note) { this.note = new Note(note); }
/** * @return The note a semitone below this one. */ public Note flattened() { Validate.isTrue(note > 0, "This note cannot be flattened because it is the lowest known note!"); return new Note(note - 1); }
/** * @return The note a semitone above this one. */ public Note sharped() { Validate.isTrue(note < 24, "This note cannot be sharped because it is the highest known note!"); return new Note(note + 1); }
/** * Creates a new note for a natural tone, such as A-natural. * * @param octave The octave where the note is in. Has to be 0 - 1. * @param tone The tone within the octave. * @return The new note. */ public static Note natural(int octave, Tone tone) { Validate.isTrue(octave != 2, "Octave cannot be 2 for naturals"); return new Note(octave, tone, false); }
@Override public void loadNbt(CompoundTag tag) { super.loadNbt(tag); note = new Note(tag.getByte("note")); }
@Override public boolean play(byte instrument, byte note) { return play(Instrument.getByType(instrument), new Note(note)); }
@Override public void playNote(Location loc, byte instrument, byte note) { playNote(loc, Instrument.getByType(instrument), new Note(note)); }
/** * Creates a new note for a flat tone, such as A-flat. * * @param octave The octave where the note is in. Has to be 0 - 1. * @param tone The tone within the octave. * @return The new note. */ public static Note flat(int octave, Tone tone) { Validate.isTrue(octave != 2, "Octave cannot be 2 for flats"); tone = tone == Tone.G ? Tone.F : Tone.values()[tone.ordinal() - 1]; return new Note(octave, tone, tone.isSharpable()); }
@Override public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) { NoteBlock noteBlock = (NoteBlock) block.getState(); Note note = noteBlock.getNote(); noteBlock.setNote(new Note(note.getId() == 24 ? 0 : note.getId() + 1)); noteBlock.update(); return noteBlock.play(); }
/** * Creates a new note for a sharp tone, such as A-sharp. * * @param octave The octave where the note is in. Has to be 0 - 2. * @param tone The tone within the octave. If the octave is 2 the note has * to be F#. * @return The new note. */ public static Note sharp(int octave, Tone tone) { return new Note(octave, tone, true); }
/** * Creates a new note for a natural tone, such as A-natural. * * @param octave The octave where the note is in. Has to be 0 - 1. * @param tone The tone within the octave. * @return The new note. */ public static Note natural(int octave, Tone tone) { Validate.isTrue(octave != 2, "Octave cannot be 2 for naturals"); return new Note(octave, tone, false); }
/** * @return The note a semitone below this one. */ public Note flattened() { Validate.isTrue(note > 0, "This note cannot be flattened because it is the lowest known note!"); return new Note(note - 1); }
/** * @return The note a semitone above this one. */ public Note sharped() { Validate.isTrue(note < 24, "This note cannot be sharped because it is the highest known note!"); return new Note(note + 1); }
public BukkitMCNote(int octave, MCTone tone, boolean sharp) throws IllegalArgumentException { n = new Note(octave, Note.Tone.valueOf(tone.name()), sharp); }
/** * Creates a new note for a flat tone, such as A-flat. * * @param octave The octave where the note is in. Has to be 0 - 1. * @param tone The tone within the octave. * @return The new note. */ public static Note flat(int octave, Tone tone) { Validate.isTrue(octave != 2, "Octave cannot be 2 for flats"); tone = tone == Tone.G ? Tone.F : Tone.values()[tone.ordinal() - 1]; return new Note(octave, tone, tone.isSharpable()); }