diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs
index 8eeef8cc..a9631206 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol18.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs
@@ -772,6 +772,15 @@ namespace MinecraftClient.Protocol.Handlers
{
ConsoleIO.WriteLineFormatted("ยง8Server is in offline mode.");
login_phase = false;
+
+ if (forgeInfo != null) {
+ // Do the forge handshake.
+ if (!CompleteForgeHandshake())
+ {
+ return false;
+ }
+ }
+
StartUpdating();
return true; //No need to check session or start encryption
}
@@ -779,6 +788,33 @@ namespace MinecraftClient.Protocol.Handlers
}
}
+ ///
+ /// Completes the Minecraft Forge handshake.
+ ///
+ /// Whether the handshake was successful.
+ private bool CompleteForgeHandshake()
+ {
+ int packetID = -1;
+ byte[] packetData = new byte[0];
+
+ while (fmlHandshakeState != FMLHandshakeClientState.DONE)
+ {
+ readNextPacket(ref packetID, ref packetData);
+
+ if (packetID == 0x40) // Disconect
+ {
+ handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, ChatParser.ParseText(readNextString(ref packetData)));
+ return false;
+ }
+ else
+ {
+ handlePacket(packetID, packetData);
+ }
+ }
+
+ return true;
+ }
+
///
/// Start network encryption. Automatically called by Login() if the server requests encryption.
///
@@ -826,6 +862,16 @@ namespace MinecraftClient.Protocol.Handlers
else if (packetID == 0x02) //Login successful
{
login_phase = false;
+
+ if (forgeInfo != null)
+ {
+ // Do the forge handshake.
+ if (!CompleteForgeHandshake())
+ {
+ return false;
+ }
+ }
+
StartUpdating();
return true;
}