diff --git a/src/main/java/com/xxmicloxx/NoteBlockAPI/NBSDecoder.java b/src/main/java/com/xxmicloxx/NoteBlockAPI/NBSDecoder.java index 332cb52..85798c3 100644 --- a/src/main/java/com/xxmicloxx/NoteBlockAPI/NBSDecoder.java +++ b/src/main/java/com/xxmicloxx/NoteBlockAPI/NBSDecoder.java @@ -63,9 +63,12 @@ private static Song parse(InputStream inputStream, File songFile) { int firstcustominstrument = 10; //Backward compatibility - most of songs with old structure are from 1.12 int firstcustominstrumentdiff; int nbsversion = 0; - if (length == 0){ + if (length == 0) { nbsversion = dataInputStream.readByte(); firstcustominstrument = dataInputStream.readByte(); + if (nbsversion >= 3) { + length = readShort(dataInputStream); + } } firstcustominstrumentdiff = InstrumentUtils.getCustomInstrumentFirstIndex() - firstcustominstrument; short songHeight = readShort(dataInputStream); @@ -110,7 +113,7 @@ private static Song parse(InputStream inputStream, File songFile) { } } - if (nbsversion > 0) { + if (nbsversion > 0 && nbsversion < 3) { length = tick; } diff --git a/src/main/java/com/xxmicloxx/NoteBlockAPI/utils/NBSDecoder.java b/src/main/java/com/xxmicloxx/NoteBlockAPI/utils/NBSDecoder.java index c82b684..dd81167 100644 --- a/src/main/java/com/xxmicloxx/NoteBlockAPI/utils/NBSDecoder.java +++ b/src/main/java/com/xxmicloxx/NoteBlockAPI/utils/NBSDecoder.java @@ -66,9 +66,12 @@ private static Song parse(InputStream inputStream, File songFile) { int firstcustominstrument = 10; //Backward compatibility - most of songs with old structure are from 1.12 int firstcustominstrumentdiff; int nbsversion = 0; - if (length == 0){ + if (length == 0) { nbsversion = dataInputStream.readByte(); firstcustominstrument = dataInputStream.readByte(); + if (nbsversion >= 3) { + length = readShort(dataInputStream); + } } firstcustominstrumentdiff = InstrumentUtils.getCustomInstrumentFirstIndex() - firstcustominstrument; short songHeight = readShort(dataInputStream); @@ -113,7 +116,7 @@ private static Song parse(InputStream inputStream, File songFile) { } } - if (nbsversion > 0) { + if (nbsversion > 0 && nbsversion < 3) { length = tick; }