Allow force-enabling Forge support for 1.13+ (#1184)

Skip login step and join even when forge info is missing in server info.
However, this only works for 1.13+. Server info retrieval is required
for enabling Forge support on older Minecraft versions.
This commit is contained in:
ORelio 2020-10-18 13:09:46 +02:00
parent 9df255dd29
commit d3f150ba12
7 changed files with 101 additions and 7 deletions

View file

@ -446,6 +446,30 @@ namespace MinecraftClient.Protocol.Handlers
|| ServerInfoCheckForgeSub(jsonData, ref forgeInfo, FMLVersion.FML2); // MC 1.13 and greater
}
/// <summary>
/// Server Info: Check if we can force-enable Forge support for this Minecraft version without using server Ping
/// </summary>
/// <param name="protocolVersion">Minecraft protocol version</param>
/// <returns>TRUE if we can force-enable Forge support without using server Ping</returns>
public static bool ServerMayForceForge(int protocolVersion)
{
return protocolVersion >= ProtocolHandler.MCVer2ProtocolVersion("1.13");
}
/// <summary>
/// Server Info: Consider Forge to be enabled regardless of server Ping
/// </summary>
/// <param name="protocolVersion">Minecraft protocol version</param>
/// <returns>ForgeInfo item stating that Forge is enabled</returns>
public static ForgeInfo ServerForceForge(int protocolVersion)
{
if (ServerMayForceForge(protocolVersion))
{
return new ForgeInfo(FMLVersion.FML2);
}
else throw new InvalidOperationException(Translations.Get("error.forgeforce"));
}
/// <summary>
/// Server Info: Check for For Forge on a Minecraft server Ping result (Handles FML and FML2
/// </summary>