From 2d3a4ccebfbc923285f576a82a5abe0a5e5eae4d Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:54:28 +0700 Subject: [PATCH] fixes OHIO --- .../chomens_bot/plugins/MusicPlayerPlugin.java | 11 ++++++++--- .../chayapak/chomens_bot/song/MidiConverter.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java index 5a58948..d53617c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java @@ -340,13 +340,18 @@ public class MusicPlayerPlugin extends Bot.Listener { blockPosition = MathUtilities.clamp(blockPosition, -0.4F, 0.4F); } + final double notShiftedFloatingPitch = Math.pow(2.0, ((note.pitch + (pitch / 10)) - 12) / 12.0); + key += 33; final boolean isMoreOrLessOctave = key < 33 || key > 57; - if (isMoreOrLessOctave) { - final double notShiftedFloatingPitch = Math.pow(2.0, ((note.pitch + (pitch / 10)) - 12) / 12.0); + final boolean shouldCustomPitch = currentSong.nbs ? + isMoreOrLessOctave : + note.pitch != note.shiftedPitch || + note.shiftedInstrument != note.instrument; + if (shouldCustomPitch) { bot.core.run( "minecraft:execute as " + CUSTOM_PITCH_SELECTOR + @@ -371,7 +376,7 @@ public class MusicPlayerPlugin extends Bot.Listener { for (int i = 0; i < amplify; i++) { bot.core.run( "minecraft:execute as " + - (isMoreOrLessOctave ? SELECTOR : BOTH_SELECTOR) + + (shouldCustomPitch ? SELECTOR : BOTH_SELECTOR) + " at @s run playsound " + (!instrument.equals("off") ? instrument : note.shiftedInstrument.sound) + " record @s ^" + blockPosition + " ^ ^ " + diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java index 1223ade..3d4d9b4 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java @@ -219,7 +219,7 @@ public class MidiConverter implements Converter { float volume = velocity / 127.0f; 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) {