From 70056b838eceff67a5adb983d1b92f993c08d890 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 31 Jan 2022 21:20:19 +0100 Subject: [PATCH] Fix missing value read Signed-off-by: Lixfel --- .../steamwar/bungeecore/listeners/mods/Forge.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 9521965..2a6a8ca 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -101,13 +101,18 @@ public class Forge extends BasicListener { } //for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29 - Utils.VarInt length = Utils.readVarInt(data, 0); - assert length.length + length.value == data.length; + Utils.VarInt channelLength = Utils.readVarInt(data, 0); + int pos = channelLength.length; + assert new String(data, pos, channelLength.value).equals("fml:handshake"); - Utils.VarInt packetId = Utils.readVarInt(data, length.length); + Utils.VarInt length = Utils.readVarInt(data, pos); + pos += length.length; + assert channelLength.length + channelLength.value + length.length + length.value == data.length; + + Utils.VarInt packetId = Utils.readVarInt(data, pos); + pos += packetId.length; assert packetId.value == 2; - int pos = length.length + packetId.length; Utils.VarInt modCount = Utils.readVarInt(data, pos); pos += modCount.length;