mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Fixed teams packet for 1.8 - 1.12.3
This commit is contained in:
parent
c8286f60c1
commit
16e3a69211
1 changed files with 64 additions and 38 deletions
|
|
@ -3044,12 +3044,22 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case PacketTypesIn.Teams:
|
||||
// Wire format per version:
|
||||
// All versions: name (string), method (byte)
|
||||
// method 0/2: displayName (component), options (byte),
|
||||
// 1.8/1.8.9 method 0/2:
|
||||
// displayName (string), prefix (string), suffix (string),
|
||||
// options (byte), nameTagVisibility, color (byte)
|
||||
// 1.9-1.12.2 method 0/2:
|
||||
// displayName (string), prefix (string), suffix (string),
|
||||
// options (byte), nameTagVisibility, collisionRule,
|
||||
// color (byte)
|
||||
// 1.13-1.21.4 method 0/2:
|
||||
// displayName (component), options (byte),
|
||||
// nameTagVisibility, collisionRule, color (VarInt),
|
||||
// prefix (component), suffix (component)
|
||||
// 1.21.5+ method 0/2:
|
||||
// displayName (component), options (byte),
|
||||
// nameTagVisibility (VarInt), collisionRule (VarInt),
|
||||
// color (VarInt), prefix (component), suffix (component)
|
||||
// method 0/3/4: players list (VarInt count + strings)
|
||||
// 1.21.5+ (protocol 770): nameTagVisibility and collisionRule are
|
||||
// VarInt-encoded enum IDs instead of UTF strings.
|
||||
var teamName = dataTypes.ReadNextString(packetData);
|
||||
var teamMethod = dataTypes.ReadNextByte(packetData);
|
||||
|
||||
|
|
@ -3063,48 +3073,64 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (teamMethod is 0 or 2)
|
||||
{
|
||||
teamDisplayName = dataTypes.ReadNextChat(packetData);
|
||||
teamFriendlyFlags = dataTypes.ReadNextByte(packetData);
|
||||
|
||||
// nameTagVisibility
|
||||
if (protocolVersion >= MC_1_21_5_Version)
|
||||
{
|
||||
// STREAM_CODEC: 0=always, 1=never, 2=hideForOtherTeams, 3=hideForOwnTeam
|
||||
teamNameTagVisibility = dataTypes.ReadNextVarInt(packetData) switch
|
||||
{
|
||||
0 => "always",
|
||||
1 => "never",
|
||||
2 => "hideForOtherTeams",
|
||||
3 => "hideForOwnTeam",
|
||||
_ => "always"
|
||||
};
|
||||
}
|
||||
else
|
||||
if (protocolVersion < MC_1_13_Version)
|
||||
{
|
||||
teamDisplayName = dataTypes.ReadNextString(packetData);
|
||||
teamPrefix = dataTypes.ReadNextString(packetData);
|
||||
teamSuffix = dataTypes.ReadNextString(packetData);
|
||||
teamFriendlyFlags = dataTypes.ReadNextByte(packetData);
|
||||
teamNameTagVisibility = dataTypes.ReadNextString(packetData);
|
||||
}
|
||||
|
||||
// collisionRule
|
||||
if (protocolVersion >= MC_1_21_5_Version)
|
||||
{
|
||||
// STREAM_CODEC: 0=always, 1=never, 2=pushOtherTeams, 3=pushOwnTeam
|
||||
teamCollisionRule = dataTypes.ReadNextVarInt(packetData) switch
|
||||
{
|
||||
0 => "always",
|
||||
1 => "never",
|
||||
2 => "pushOtherTeams",
|
||||
3 => "pushOwnTeam",
|
||||
_ => "always"
|
||||
};
|
||||
if (protocolVersion >= MC_1_9_Version)
|
||||
teamCollisionRule = dataTypes.ReadNextString(packetData);
|
||||
|
||||
teamColor = unchecked((sbyte)dataTypes.ReadNextByte(packetData));
|
||||
}
|
||||
else
|
||||
{
|
||||
teamCollisionRule = dataTypes.ReadNextString(packetData);
|
||||
}
|
||||
teamDisplayName = dataTypes.ReadNextChat(packetData);
|
||||
teamFriendlyFlags = dataTypes.ReadNextByte(packetData);
|
||||
|
||||
teamColor = dataTypes.ReadNextVarInt(packetData);
|
||||
teamPrefix = dataTypes.ReadNextChat(packetData);
|
||||
teamSuffix = dataTypes.ReadNextChat(packetData);
|
||||
// nameTagVisibility
|
||||
if (protocolVersion >= MC_1_21_5_Version)
|
||||
{
|
||||
// STREAM_CODEC: 0=always, 1=never, 2=hideForOtherTeams, 3=hideForOwnTeam
|
||||
teamNameTagVisibility = dataTypes.ReadNextVarInt(packetData) switch
|
||||
{
|
||||
0 => "always",
|
||||
1 => "never",
|
||||
2 => "hideForOtherTeams",
|
||||
3 => "hideForOwnTeam",
|
||||
_ => "always"
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
teamNameTagVisibility = dataTypes.ReadNextString(packetData);
|
||||
}
|
||||
|
||||
// collisionRule
|
||||
if (protocolVersion >= MC_1_21_5_Version)
|
||||
{
|
||||
// STREAM_CODEC: 0=always, 1=never, 2=pushOtherTeams, 3=pushOwnTeam
|
||||
teamCollisionRule = dataTypes.ReadNextVarInt(packetData) switch
|
||||
{
|
||||
0 => "always",
|
||||
1 => "never",
|
||||
2 => "pushOtherTeams",
|
||||
3 => "pushOwnTeam",
|
||||
_ => "always"
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
teamCollisionRule = dataTypes.ReadNextString(packetData);
|
||||
}
|
||||
|
||||
teamColor = dataTypes.ReadNextVarInt(packetData);
|
||||
teamPrefix = dataTypes.ReadNextChat(packetData);
|
||||
teamSuffix = dataTypes.ReadNextChat(packetData);
|
||||
}
|
||||
}
|
||||
|
||||
var teamPlayers = new List<string>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue