mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix 1.19.3 message signature issue
This commit is contained in:
parent
8cdd32a52a
commit
3735cab9dd
5 changed files with 52 additions and 16 deletions
|
|
@ -2417,6 +2417,11 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
public void OnGameJoined(bool isOnlineMode)
|
||||
{
|
||||
if (protocolversion < Protocol18Handler.MC_1_19_3_Version || playerKeyPair == null || !isOnlineMode)
|
||||
SetCanSendMessage(true);
|
||||
else
|
||||
SetCanSendMessage(false);
|
||||
|
||||
string? bandString = Config.Main.Advanced.BrandInfo.ToBrandString();
|
||||
if (!String.IsNullOrWhiteSpace(bandString))
|
||||
handler.SendBrandInfo(bandString.Trim());
|
||||
|
|
@ -2435,9 +2440,6 @@ namespace MinecraftClient
|
|||
&& playerKeyPair != null && isOnlineMode)
|
||||
handler.SendPlayerSession(playerKeyPair);
|
||||
|
||||
if (protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
||||
CanSendMessage = true;
|
||||
|
||||
if (inventoryHandlingRequested)
|
||||
{
|
||||
inventoryHandlingRequested = false;
|
||||
|
|
@ -3482,9 +3484,10 @@ namespace MinecraftClient
|
|||
ConsoleIO.OnAutoCompleteDone(transactionId, result);
|
||||
}
|
||||
|
||||
public void OnDeclareCommands()
|
||||
public void SetCanSendMessage(bool canSendMessage)
|
||||
{
|
||||
CanSendMessage = true;
|
||||
CanSendMessage = canSendMessage;
|
||||
Log.Debug("CanSendMessage = " + canSendMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -75,8 +75,9 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
private readonly BlockingCollection<Tuple<int, Queue<byte>>> packetQueue = new();
|
||||
private float LastYaw, LastPitch;
|
||||
|
||||
private bool receiveDeclareCommands = false, receivePlayerInfo = false;
|
||||
private object MessageSigningLock = new();
|
||||
private Guid chatUuid = Guid.Empty;
|
||||
private Guid chatUuid = Guid.NewGuid();
|
||||
private int pendingAcknowledgments = 0, messageIndex = 0;
|
||||
private LastSeenMessagesCollector lastSeenMessagesCollector;
|
||||
private LastSeenMessageList.AcknowledgedMessage? lastReceivedMessage = null;
|
||||
|
|
@ -367,7 +368,19 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
SendPacket(PacketTypesOut.Pong, packetData);
|
||||
break;
|
||||
case PacketTypesIn.JoinGame:
|
||||
{ // Temporary fix
|
||||
log.Debug("Receive JoinGame");
|
||||
|
||||
receiveDeclareCommands = receivePlayerInfo = false;
|
||||
|
||||
messageIndex = 0;
|
||||
pendingAcknowledgments = 0;
|
||||
|
||||
lastReceivedMessage = null;
|
||||
lastSeenMessagesCollector = protocolVersion >= MC_1_19_3_Version ? new(20) : new(5);
|
||||
}
|
||||
handler.OnGameJoined(isOnlineMode);
|
||||
|
||||
int playerEntityID = dataTypes.ReadNextInt(packetData);
|
||||
handler.OnReceivePlayerEntityID(playerEntityID);
|
||||
|
||||
|
|
@ -467,8 +480,11 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case PacketTypesIn.DeclareCommands:
|
||||
if (protocolVersion >= MC_1_19_Version)
|
||||
{
|
||||
log.Debug("Receive DeclareCommands");
|
||||
DeclareCommands.Read(dataTypes, packetData, protocolVersion);
|
||||
handler.OnDeclareCommands();
|
||||
receiveDeclareCommands = true;
|
||||
if (receivePlayerInfo)
|
||||
handler.SetCanSendMessage(true);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.ChatMessage:
|
||||
|
|
@ -1404,10 +1420,28 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte[] encodedPublicKey = dataTypes.ReadNextByteArray(packetData);
|
||||
byte[] publicKeySignature = dataTypes.ReadNextByteArray(packetData);
|
||||
player.SetPublicKey(chatUuid, publicKeyExpiryTime, encodedPublicKey, publicKeySignature);
|
||||
|
||||
if (playerUuid == handler.GetUserUuid())
|
||||
{
|
||||
log.Debug("Receive ChatUuid = " + chatUuid);
|
||||
this.chatUuid = chatUuid;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearPublicKey();
|
||||
|
||||
if (playerUuid == handler.GetUserUuid())
|
||||
{
|
||||
log.Debug("Receive ChatUuid = Empty");
|
||||
}
|
||||
}
|
||||
|
||||
if (playerUuid == handler.GetUserUuid())
|
||||
{
|
||||
receivePlayerInfo = true;
|
||||
if (receiveDeclareCommands)
|
||||
handler.SetCanSendMessage(true);
|
||||
}
|
||||
}
|
||||
if ((actionBitset & 1 << 2) > 0) // Actions bit 2: update gamemode
|
||||
|
|
@ -3392,7 +3426,6 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
List<byte> packet = new();
|
||||
|
||||
chatUuid = Guid.NewGuid();
|
||||
packet.AddRange(DataTypes.GetUUID(chatUuid));
|
||||
packet.AddRange(DataTypes.GetLong(playerKeyPair.GetExpirationMilliseconds()));
|
||||
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.Key.Length));
|
||||
|
|
@ -3400,6 +3433,8 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.SignatureV2!.Length));
|
||||
packet.AddRange(playerKeyPair.PublicKey.SignatureV2);
|
||||
|
||||
log.Debug($"SendPlayerSession MessageUUID = {chatUuid.ToString()}, len(PublicKey) = {playerKeyPair.PublicKey.Key.Length}, len(SignatureV2) = {playerKeyPair.PublicKey.SignatureV2!.Length}");
|
||||
|
||||
SendPacket(PacketTypesOut.PlayerSession, packet);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="result">All commands.</param>
|
||||
public void OnAutoCompleteDone(int transactionId, string[] result);
|
||||
|
||||
public void OnDeclareCommands();
|
||||
public void SetCanSendMessage(bool canSendMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Send a click container button packet to the server.
|
||||
|
|
|
|||
|
|
@ -302,11 +302,9 @@ namespace MinecraftClient.Protocol.Message
|
|||
catch (Exception e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
|
||||
if (Config.Logging.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLine(e.Message);
|
||||
ConsoleIO.WriteLine(e.StackTrace ?? "");
|
||||
}
|
||||
ConsoleIO.WriteLine(e.Message);
|
||||
if (Config.Logging.DebugMessages && !string.IsNullOrEmpty(e.StackTrace))
|
||||
ConsoleIO.WriteLine(e.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -705,7 +705,7 @@ namespace MinecraftClient
|
|||
public bool SignMessageInCommand = true;
|
||||
|
||||
[TomlInlineComment("$Signature.MarkLegallySignedMsg$")]
|
||||
public bool MarkLegallySignedMsg = false;
|
||||
public bool MarkLegallySignedMsg = true;
|
||||
|
||||
[TomlInlineComment("$Signature.MarkModifiedMsg$")]
|
||||
public bool MarkModifiedMsg = true;
|
||||
|
|
@ -714,7 +714,7 @@ namespace MinecraftClient
|
|||
public bool MarkIllegallySignedMsg = true;
|
||||
|
||||
[TomlInlineComment("$Signature.MarkSystemMessage$")]
|
||||
public bool MarkSystemMessage = false;
|
||||
public bool MarkSystemMessage = true;
|
||||
|
||||
[TomlInlineComment("$Signature.ShowModifiedChat$")]
|
||||
public bool ShowModifiedChat = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue