From 966305518e64923a8561b432ad6443917e1ba64c Mon Sep 17 00:00:00 2001 From: umutcagand Date: Fri, 2 Oct 2026 16:57:15 +0300 Subject: [PATCH] Respect NBS vanilla instrument counts when skipping custom notes --- .../utils/notebot/decoder/NBSSongDecoder.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java index 172f3fbd783..cb5c93a3592 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java @@ -51,9 +51,10 @@ private Song parse(InputStream inputStream) throws Exception { DataInputStream dataInputStream = new DataInputStream(inputStream); short length = readShort(dataInputStream); int nbsversion = 0; + int vanillaInstrumentCount = 10; // The original format has 10 vanilla instruments. if (length == 0) { - nbsversion = dataInputStream.readByte(); - dataInputStream.readByte(); // first custom instrument + nbsversion = dataInputStream.readUnsignedByte(); + vanillaInstrumentCount = dataInputStream.readUnsignedByte(); if (nbsversion >= 3) { length = readShort(dataInputStream); } @@ -91,7 +92,7 @@ private Song parse(InputStream inputStream) throws Exception { if (jumpLayers == 0) { break; } - byte instrument = dataInputStream.readByte(); + int instrument = dataInputStream.readUnsignedByte(); byte key = dataInputStream.readByte(); if (nbsversion >= 4) { @@ -100,9 +101,12 @@ private Song parse(InputStream inputStream) throws Exception { readShort(dataInputStream); // note block pitch } + // Custom instruments start at the count stored in the file, not necessarily 16. + if (instrument >= vanillaInstrumentCount) continue; + NoteBlockInstrument inst = fromNBSInstrument(instrument); - // Probably a custom instrument. Ignore this note + // Unsupported vanilla instrument. Ignore this note if (inst == null) continue; Note note = new Note(inst /* instrument */, key - NOTE_OFFSET /* note */);