Fixed incorrect handling in 1.18(1.18.1) and 1.18.2

This commit is contained in:
BruceChen 2022-07-24 22:21:15 +08:00
parent 3429989527
commit 59ed18bb40
5 changed files with 15 additions and 7 deletions

View file

@ -327,7 +327,7 @@ namespace MinecraftClient
/// <param name="action">0 to create/update an item. 1 to remove an item.</param> /// <param name="action">0 to create/update an item. 1 to remove an item.</param>
/// <param name="objectivename">The name of the objective the score belongs to</param> /// <param name="objectivename">The name of the objective the score belongs to</param>
/// <param name="value">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param> /// <param name="value">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
public virtual void OnUpdateScore(string entityname, byte action, string objectivename, int value) { } public virtual void OnUpdateScore(string entityname, int action, string objectivename, int value) { }
/// <summary> /// <summary>
/// Called when an inventory/container was updated by server /// Called when an inventory/container was updated by server

View file

@ -2490,7 +2490,7 @@ namespace MinecraftClient
/// <param name="action">0 to create/update an item. 1 to remove an item.</param> /// <param name="action">0 to create/update an item. 1 to remove an item.</param>
/// <param name="objectivename">The name of the objective the score belongs to</param> /// <param name="objectivename">The name of the objective the score belongs to</param>
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param> /// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
public void OnUpdateScore(string entityname, byte action, string objectivename, int value) public void OnUpdateScore(string entityname, int action, string objectivename, int value)
{ {
DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value)); DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value));
} }

View file

@ -410,6 +410,9 @@ namespace MinecraftClient.Protocol.Handlers
if (living) if (living)
{ {
if (protocolversion >= Protocol18Handler.MC1182Version)
entityYaw = ReadNextByte(cache);
else
entityPitch = ReadNextByte(cache); entityPitch = ReadNextByte(cache);
} }
else else

View file

@ -1208,7 +1208,7 @@ namespace MinecraftClient.Protocol.Handlers
break; break;
case PacketTypesIn.UpdateScore: case PacketTypesIn.UpdateScore:
string entityname = dataTypes.ReadNextString(packetData); string entityname = dataTypes.ReadNextString(packetData);
byte action3 = dataTypes.ReadNextByte(packetData); int action3 = protocolversion >= MC1182Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextByte(packetData);
string objectivename2 = null; string objectivename2 = null;
int value = -1; int value = -1;
if (action3 != 1 || protocolversion >= MC18Version) if (action3 != 1 || protocolversion >= MC18Version)
@ -1713,7 +1713,12 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolversion >= MC19Version) if (protocolversion >= MC19Version)
fields.AddRange(dataTypes.GetVarInt(mainHand)); fields.AddRange(dataTypes.GetVarInt(mainHand));
if (protocolversion >= MC117Version) if (protocolversion >= MC117Version)
fields.Add(1); // 1.17 and above - Disable text filtering. (Always true) {
if (protocolversion == MC117Version || protocolversion == MC1171Version)
fields.Add(1); // 1.17 and 1.17.1 - Disable text filtering. (Always true)
else
fields.Add(0); // 1.18 and above - Enable text filtering. (Always false)
}
if (protocolversion >= MC1181Version) if (protocolversion >= MC1181Version)
fields.Add(1); // 1.18 and above - Allow server listings fields.Add(1); // 1.18 and above - Allow server listings
SendPacket(PacketTypesOut.ClientSettings, fields); SendPacket(PacketTypesOut.ClientSettings, fields);
@ -2040,7 +2045,7 @@ namespace MinecraftClient.Protocol.Handlers
packet.AddRange(arrayOfSlots); packet.AddRange(arrayOfSlots);
} }
packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); // Clicked item packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); // Carried item (Clicked item)
log.Info("Packet data: " + dataTypes.ByteArrayToString(packet.ToArray())); log.Info("Packet data: " + dataTypes.ByteArrayToString(packet.ToArray()));

View file

@ -374,7 +374,7 @@ namespace MinecraftClient.Protocol
/// <param name="action">0 to create/update an item. 1 to remove an item.</param> /// <param name="action">0 to create/update an item. 1 to remove an item.</param>
/// <param name="objectivename">The name of the objective the score belongs to</param> /// <param name="objectivename">The name of the objective the score belongs to</param>
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param> /// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
void OnUpdateScore(string entityname, byte action, string objectivename, int value); void OnUpdateScore(string entityname, int action, string objectivename, int value);
/// <summary> /// <summary>
/// Called when tradeList is received from server /// Called when tradeList is received from server