Skip to content

Commit

Permalink
add context.pitch to note play event
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 6, 2020
1 parent acb64c4 commit c5d3c5e
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -29,6 +29,7 @@ public class NoteBlockPlaysNoteScriptEvent extends BukkitScriptEvent implements
// <context.tone> returns the the note tone played (A to G).
// <context.octave> returns the octave the note is played at (as a number).
// <context.sharp> returns a boolean indicating whether the note is sharp.
// <context.pitch> returns the computed pitch value (that fits into <@link command playsound>). Note that volume is always 3.
//
// -->

Expand Down Expand Up @@ -78,6 +79,10 @@ else if (name.equals("octave")) {
else if (name.equals("sharp")) {
return new ElementTag(event.getNote().isSharped());
}
else if (name.equals("pitch")) {
double pitch = Math.pow(2.0, (double)(event.getNote().getId() - 12) / 12.0); // based on minecraft source
return new ElementTag(pitch);
}
return super.getContext(name);
}

Expand Down

0 comments on commit c5d3c5e

Please sign in to comment.