From b8db91bff67c3546989b3c11796151924f9d5644 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sat, 30 Dec 2023 16:23:23 +0200 Subject: [PATCH] fix: minecraft BCC support By Douile, backported, reference #436 --- protocols/minecraftvanilla.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/protocols/minecraftvanilla.js b/protocols/minecraftvanilla.js index 971f1cb..b788186 100644 --- a/protocols/minecraftvanilla.js +++ b/protocols/minecraftvanilla.js @@ -39,7 +39,9 @@ class MinecraftVanilla extends Core { const strLen = reader.varint(); this.debugLog("String Length: "+strLen); - const str = reader.rest().toString('utf8'); + const rest = reader.rest() + + const str = rest.toString('utf8', 0, strLen) this.debugLog(str); const json = JSON.parse(str.substring(0, strLen)); @@ -67,8 +69,8 @@ class MinecraftVanilla extends Core { // Better Compatibility Checker mod support let bccJson = {} - if (str.length > strLen) { - const bccStr = str.substring(strLen + 1); + if (rest.length > strLen) { + const bccStr = rest.toString('utf8', strLen + 1); bccJson = JSON.parse(bccStr); }