fixes OHIO

This commit is contained in:
Chayapak 2023-10-04 17:54:28 +07:00
parent bead13d6ec
commit 2d3a4ccebf
2 changed files with 9 additions and 4 deletions

View file

@ -340,13 +340,18 @@ public class MusicPlayerPlugin extends Bot.Listener {
blockPosition = MathUtilities.clamp(blockPosition, -0.4F, 0.4F); blockPosition = MathUtilities.clamp(blockPosition, -0.4F, 0.4F);
} }
final double notShiftedFloatingPitch = Math.pow(2.0, ((note.pitch + (pitch / 10)) - 12) / 12.0);
key += 33; key += 33;
final boolean isMoreOrLessOctave = key < 33 || key > 57; final boolean isMoreOrLessOctave = key < 33 || key > 57;
if (isMoreOrLessOctave) { final boolean shouldCustomPitch = currentSong.nbs ?
final double notShiftedFloatingPitch = Math.pow(2.0, ((note.pitch + (pitch / 10)) - 12) / 12.0); isMoreOrLessOctave :
note.pitch != note.shiftedPitch ||
note.shiftedInstrument != note.instrument;
if (shouldCustomPitch) {
bot.core.run( bot.core.run(
"minecraft:execute as " + "minecraft:execute as " +
CUSTOM_PITCH_SELECTOR + CUSTOM_PITCH_SELECTOR +
@ -371,7 +376,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
for (int i = 0; i < amplify; i++) { for (int i = 0; i < amplify; i++) {
bot.core.run( bot.core.run(
"minecraft:execute as " + "minecraft:execute as " +
(isMoreOrLessOctave ? SELECTOR : BOTH_SELECTOR) + (shouldCustomPitch ? SELECTOR : BOTH_SELECTOR) +
" at @s run playsound " + " at @s run playsound " +
(!instrument.equals("off") ? instrument : note.shiftedInstrument.sound) + (!instrument.equals("off") ? instrument : note.shiftedInstrument.sound) +
" record @s ^" + blockPosition + " ^ ^ " + " record @s ^" + blockPosition + " ^ ^ " +

View file

@ -219,7 +219,7 @@ public class MidiConverter implements Converter {
float volume = velocity / 127.0f; float volume = velocity / 127.0f;
long time = microTime / 1000L; long time = microTime / 1000L;
return new Note(instrumentList[0], shiftedInstrument, shiftedInstrumentPitch, pitch, midiPitch, volume, time, (int) ((panning - 64) / (float) 64) * 100, 100); return new Note(instrumentList[0], shiftedInstrument, pitch, shiftedInstrumentPitch, midiPitch, volume, time, (int) ((panning - 64) / (float) 64) * 100, 100);
} }
private static Note getMidiPercussionNote (int midiPitch, float velocity, long microTime, int panning) { private static Note getMidiPercussionNote (int midiPitch, float velocity, long microTime, int panning) {