Added Player Killed event (Combat and CombatDeath packets).

This commit is contained in:
Milutinke 2022-10-26 20:53:09 +02:00
parent 01eee22921
commit 80e227c3a7
5 changed files with 65 additions and 1 deletions

View file

@ -596,6 +596,33 @@ namespace MinecraftClient.Protocol.Handlers
Acknowledge(chat);
handler.OnTextReceived(chat);
}
break;
case PacketTypesIn.CombatEvent:
// 1.8 - 1.16.5
if (protocolVersion >= MC_1_8_Version && protocolVersion <= MC_1_16_5_Version)
{
CombatEventType eventType = (CombatEventType)dataTypes.ReadNextVarInt(packetData);
if (eventType == CombatEventType.EntityDead)
{
dataTypes.SkipNextVarInt(packetData);
handler.OnPlayerKilled(
dataTypes.ReadNextInt(packetData),
ChatParser.ParseText(dataTypes.ReadNextString(packetData))
);
}
}
break;
case PacketTypesIn.DeathCombatEvent:
dataTypes.SkipNextVarInt(packetData);
handler.OnPlayerKilled(
dataTypes.ReadNextInt(packetData),
ChatParser.ParseText(dataTypes.ReadNextString(packetData))
);
break;
case PacketTypesIn.MessageHeader:
if (protocolVersion >= MC_1_19_2_Version)