From b746b5612bba112c89cd643f25fab7749eed1101 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sat, 24 Oct 2015 22:56:35 -0700 Subject: [PATCH] Only add `\0FML\0` to the IP if forgeinfo is not null (+ whitespace fixes) --- MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs | 2 +- MinecraftClient/Protocol/Handlers/Protocol18.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs b/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs index dd3a83de..03180432 100755 --- a/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs +++ b/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs @@ -38,7 +38,7 @@ namespace MinecraftClient.Protocol.Handlers.Forge /// The modinfo JSON tag. internal ForgeInfo(Json.JSONData data) { - // Example ModInfo (with spacing): + // Example ModInfo (with spacing): // "modinfo": { // "type": "FML", diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 8fc5eaae..e8dd5adf 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -223,7 +223,7 @@ namespace MinecraftClient.Protocol.Handlers if (channel == "FML|HS") { FMLHandshakeDiscriminator discriminator = (FMLHandshakeDiscriminator)readNextByte(ref packetData); - + if (discriminator == FMLHandshakeDiscriminator.HandshakeReset) { fmlHandshakeState = FMLHandshakeClientState.START; @@ -259,7 +259,7 @@ namespace MinecraftClient.Protocol.Handlers ForgeInfo.ForgeMod mod = forgeInfo.Mods[i]; mods[i] = concatBytes(getString(mod.ModID), getString(mod.Version)); } - SendForgeHandshakePacket(FMLHandshakeDiscriminator.ModList, + SendForgeHandshakePacket(FMLHandshakeDiscriminator.ModList, concatBytes(getVarInt(forgeInfo.Mods.Count), concatBytes(mods))); fmlHandshakeState = FMLHandshakeClientState.WAITINGSERVERDATA; @@ -694,7 +694,7 @@ namespace MinecraftClient.Protocol.Handlers public bool Login() { byte[] protocol_version = getVarInt(protocolversion); - byte[] server_adress_val = Encoding.UTF8.GetBytes(handler.GetServerHost() + "\0FML\0"); + byte[] server_adress_val = Encoding.UTF8.GetBytes(handler.GetServerHost() + (forgeInfo != null ? "\0FML\0" : "")); byte[] server_adress_len = getVarInt(server_adress_val.Length); byte[] server_port = BitConverter.GetBytes((ushort)handler.GetServerPort()); Array.Reverse(server_port); byte[] next_state = getVarInt(2);