From dc0021d99092e99f892aa1e6a51a8940c44a1cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Tue, 28 Jun 2022 17:09:08 +0200 Subject: [PATCH] Fixed entity health update event (This will also fix the Auto Attack bot) --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index e8ed9d4b..81aae204 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1059,7 +1059,14 @@ namespace MinecraftClient.Protocol.Handlers { int EntityID = dataTypes.ReadNextVarInt(packetData); Dictionary metadata = dataTypes.ReadNextMetadata(packetData, itemPalette); - int healthField = protocolversion >= MC114Version ? 8 : 7; // Health is field no. 7 in 1.10+ and 8 in 1.14+ + + int healthField = 7; // From 1.10 to 1.14 (excluding 1.14) + + if (protocolversion >= MC114Version && protocolversion <= MC1165Version) + healthField = 8; + else if (protocolversion >= MC117Version) + healthField = 9; + if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float)) handler.OnEntityHealth(EntityID, (float)metadata[healthField]); handler.OnEntityMetadata(EntityID, metadata);