Skip to content

Commit 883ed12

Browse files
authored
feat: Patch the client to support Hypixel
feat: Patch the client to support Hypixel
2 parents 61c2cbf + 98d4781 commit 883ed12

14 files changed

Lines changed: 364 additions & 47 deletions

File tree

MinecraftClient/Logger/FileLogLogger.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ public override void Debug(string msg)
9090
}
9191
}
9292

93+
public override void PacketDebug(string msg)
94+
{
95+
if (Settings.Config.Logging.PacketDebugMessages)
96+
{
97+
if (ShouldDisplay(FilterChannel.Debug, msg))
98+
{
99+
LogAndSave("§8[DEBUG] " + msg);
100+
}
101+
}
102+
}
103+
93104
public override void Error(string msg)
94105
{
95106
base.Error(msg);

MinecraftClient/Logger/FilteredLogger.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ public override void Debug(string msg)
5757
}
5858
}
5959

60+
public override void PacketDebug(string msg)
61+
{
62+
if (Settings.Config.Logging.PacketDebugMessages)
63+
{
64+
if (ShouldDisplay(FilterChannel.Debug, msg))
65+
{
66+
Log("§8[DEBUG] " + msg);
67+
}
68+
}
69+
}
70+
6071
public override void Info(string msg)
6172
{
6273
if (InfoEnabled)

MinecraftClient/Logger/ILogger.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public interface ILogger
1616
void Debug(string msg, params object[] args);
1717
void Debug(object msg);
1818

19+
void PacketDebug(string msg);
20+
void PacketDebug(string msg, params object[] args);
21+
void PacketDebug(object msg);
22+
1923
void Warn(string msg);
2024
void Warn(string msg, params object[] args);
2125
void Warn(object msg);

MinecraftClient/Logger/LoggerBase.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ public void Debug(object msg)
4040
Debug(msg.ToString() ?? string.Empty);
4141
}
4242

43+
public abstract void PacketDebug(string msg);
44+
45+
public void PacketDebug(string msg, params object[] args)
46+
{
47+
PacketDebug(string.Format(msg, args));
48+
}
49+
50+
public void PacketDebug(object msg)
51+
{
52+
PacketDebug(msg.ToString() ?? string.Empty);
53+
}
54+
4355
public abstract void Error(string msg);
4456

4557
public void Error(string msg, params object[] args)

MinecraftClient/McClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3435,7 +3435,8 @@ public void OnGameJoined(bool isOnlineMode)
34353435
if (!String.IsNullOrWhiteSpace(bandString))
34363436
handler.SendBrandInfo(bandString.Trim());
34373437

3438-
if (Config.MCSettings.Enabled)
3438+
// 1.20.2+ expects ClientInformation during configuration; older servers still want it here.
3439+
if (Config.MCSettings.Enabled && protocolversion < Protocol18Handler.MC_1_20_2_Version)
34393440
handler.SendClientSettings(
34403441
Config.MCSettings.Locale,
34413442
Config.MCSettings.RenderDistance,

MinecraftClient/Protocol/Handlers/DataTypes.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,17 +1424,24 @@ public string ReadNextChat(Queue<byte> cache)
14241424
{
14251425
if (protocolversion >= Protocol18Handler.MC_1_20_4_Version)
14261426
{
1427-
// Read as NBT
1428-
var r = ReadNextNbt(cache);
1429-
var msg = ChatParser.ParseText(r);
1430-
return msg;
1431-
}
1432-
else
1433-
{
1434-
// Read as String
1435-
var json = ReadNextString(cache);
1436-
return ChatParser.ParseText(json);
1427+
// Vanilla 1.20.4+ uses NBT here, but Hypixel exposed a JSON-string fallback on the same path.
1428+
Queue<byte> fallbackCache = new(cache);
1429+
try
1430+
{
1431+
var r = ReadNextNbt(cache);
1432+
return ChatParser.ParseText(r);
1433+
}
1434+
catch (System.IO.InvalidDataException)
1435+
{
1436+
cache.Clear();
1437+
foreach (var b in fallbackCache)
1438+
cache.Enqueue(b);
1439+
}
14371440
}
1441+
1442+
// Read as String
1443+
var json = ReadNextString(cache);
1444+
return ChatParser.ParseText(json);
14381445
}
14391446

14401447
/// <summary>

0 commit comments

Comments
 (0)