From 26ea5103120f37627a4caac5b70303940a4aaf65 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 3 Dec 2023 04:40:45 +0200 Subject: [PATCH] feat: add support for the minecraft BCC mod (#429) --- CHANGELOG.md | 1 + protocols/minecraftvanilla.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acdb4ae..291a1ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### 4.3.0 * Fix `Post Scriptum` not being on the valve protocol. * Fix `Epic` protocol's `numplayers` not being in the `raw` field. +* Added support for the Minecraft [Better Compatibility Checker](https://www.curseforge.com/minecraft/mc-mods/better-compatibility-checker) Mod. ### 4.2.0 * Renamed `Counter Strike: 2D` to `CS2D` in [games.txt](games.txt) (why? see [this](https://cs2d.com/faq.php?show=misc_name#misc_name)). diff --git a/protocols/minecraftvanilla.js b/protocols/minecraftvanilla.js index 45dd6c5..971f1cb 100644 --- a/protocols/minecraftvanilla.js +++ b/protocols/minecraftvanilla.js @@ -42,7 +42,7 @@ class MinecraftVanilla extends Core { const str = reader.rest().toString('utf8'); this.debugLog(str); - const json = JSON.parse(str); + const json = JSON.parse(str.substring(0, strLen)); delete json.favicon; state.raw = json; @@ -63,6 +63,16 @@ class MinecraftVanilla extends Core { for (let i = state.players.length; i < Math.min(json.players.online, 10000); i++) { state.players.push({}); } + + // Better Compatibility Checker mod support + let bccJson = {} + + if (str.length > strLen) { + const bccStr = str.substring(strLen + 1); + bccJson = JSON.parse(bccStr); + } + + state.raw.bcc = bccJson; } varIntBuffer(num) {