0x42 S42PacketCombatEvent

Server sends combat-related events: enter combat, end combat, entity dead with death message.

Clientbound (Server → Client) · PLAY · net/minecraft/network/play/server/S42PacketCombatEvent.java

Published 2026-06-18 · Updated 2026-10-14

combatplayerdeathentity
Complete 6/8

Fields

FieldTypeDescription
eventEnumENTER_COMBAT, END_COMBAT, ENTITY_DIED
durationVarIntFor END_COMBAT: duration in ticks
playerIDintFor ENTITY_DIED: victim entity ID
entityIDintFor ENTITY_DIED: killer entity ID
messageIChatComponentFor ENTITY_DIED: death message

Wire Encoding

FieldTypeNotes
EventVarInt Enum0=enter,1=end,2=dead
Duration (if end)VarInt
Player (if dead)int
Entity (if dead)int
Message (if dead)Chat Component

MCP References

MCPNetHandlerPlayClient.handleCombatEvent()

Handler Interface

HNDINetHandlerPlayClient

Vanilla Source

S42PacketCombatEvent.java96 lines · MCP 1.8.9Original ↗
1
package net.minecraft.network.play.server;
2
3
import java.io.IOException;
4
import net.minecraft.entity.EntityLivingBase;
5
import net.minecraft.network.Packet;
6
import net.minecraft.network.PacketBuffer;
7
import net.minecraft.network.play.INetHandlerPlayClient;
8
import net.minecraft.util.CombatTracker;
9
10
public class S42PacketCombatEvent implements Packet<INetHandlerPlayClient>
11
{
12
    public S42PacketCombatEvent.Event eventType;
13
    public int field_179774_b;
14
    public int field_179775_c;
15
    public int field_179772_d;
16
    public String deathMessage;
17
18
    public S42PacketCombatEvent()
19
    {
20
    }
21
22
    @SuppressWarnings("incomplete-switch")
23
    public S42PacketCombatEvent(CombatTracker combatTrackerIn, S42PacketCombatEvent.Event combatEventType)
24
    {
25
        this.eventType = combatEventType;
26
        EntityLivingBase entitylivingbase = combatTrackerIn.func_94550_c();
27
28
        switch (combatEventType)
29
        {
30
            case END_COMBAT:
31
                this.field_179772_d = combatTrackerIn.func_180134_f();
32
                this.field_179775_c = entitylivingbase == null ? -1 : entitylivingbase.getEntityId();
33
                break;
34
35
            case ENTITY_DIED:
36
                this.field_179774_b = combatTrackerIn.getFighter().getEntityId();
37
                this.field_179775_c = entitylivingbase == null ? -1 : entitylivingbase.getEntityId();
38
                this.deathMessage = combatTrackerIn.getDeathMessage().getUnformattedText();
39
        }
40
    }
41
42
    /**
43
     * Reads the raw packet data from the data stream.
44
     */
45
    public void readPacketData(PacketBuffer buf) throws IOException
46
    {
47
        this.eventType = (S42PacketCombatEvent.Event)buf.readEnumValue(S42PacketCombatEvent.Event.class);
48
49
        if (this.eventType == S42PacketCombatEvent.Event.END_COMBAT)
50
        {
51
            this.field_179772_d = buf.readVarIntFromBuffer();
52
            this.field_179775_c = buf.readInt();
53
        }
54
        else if (this.eventType == S42PacketCombatEvent.Event.ENTITY_DIED)
55
        {
56
            this.field_179774_b = buf.readVarIntFromBuffer();
57
            this.field_179775_c = buf.readInt();
58
            this.deathMessage = buf.readStringFromBuffer(32767);
59
        }
60
    }
61
62
    /**
63
     * Writes the raw packet data to the data stream.
64
     */
65
    public void writePacketData(PacketBuffer buf) throws IOException
66
    {
67
        buf.writeEnumValue(this.eventType);
68
69
        if (this.eventType == S42PacketCombatEvent.Event.END_COMBAT)
70
        {
71
            buf.writeVarIntToBuffer(this.field_179772_d);
72
            buf.writeInt(this.field_179775_c);
73
        }
74
        else if (this.eventType == S42PacketCombatEvent.Event.ENTITY_DIED)
75
        {
76
            buf.writeVarIntToBuffer(this.field_179774_b);
77
            buf.writeInt(this.field_179775_c);
78
            buf.writeString(this.deathMessage);
79
        }
80
    }
81
82
    /**
83
     * Passes this Packet on to the NetHandler for processing.
84
     */
85
    public void processPacket(INetHandlerPlayClient handler)
86
    {
87
        handler.handleCombatEvent(this);
88
    }
89
90
    public static enum Event
91
    {
92
        ENTER_COMBAT,
93
        END_COMBAT,
94
        ENTITY_DIED;
95
    }
96
}

Deobfuscated MCP 1.8.9 source of S42PacketCombatEvent, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/play/server/S42PacketCombatEvent.java) at build time and verified present.

Deep Dive

Role in the protocol

Combat tracker state machine. The server announces combat tag transitions through ENTER_COMBAT and END_COMBAT, with a third variant ENTITY_DIED defined for death broadcasts. EntityPlayerMP sends ENTER_COMBAT from func_152111_bt when combat starts and END_COMBAT from func_152112_bu when it ends; END_COMBAT carries the fight duration in ticks and the tracked entity's ID. Only the clientbound direction exists: the client never acknowledges combat state.

Vanilla handling

The client handler func_175098_a resolves the tracked entity by ID and feeds Twitch streaming metadata: END_COMBAT becomes a MetadataCombat with a negative timestamp derived from the duration (1000 * duration / 20), and ENTITY_DIED becomes a MetadataPlayerDeath carrying the victim, the killer entity and the death message. Nothing in the handler touches the death screen, the health bar or the tab list; those are driven by the client's own entity state.

Why clients touch it

No module in the 8 clients references S42. This is the natural home for death-event hooks (AutoGG, kill counting, KillAura target cleanup), yet the corpus shows none: AutoGG modules in these clients key off S02PacketChat death-message patterns instead, and KillAura cleanup keys off S13PacketDestroyEntities. The structural reason is that the vanilla server never sends ENTITY_DIED: EntityPlayerMP.onDeath broadcasts the death message through ServerConfigurationManager chat (becoming S02PacketChat on the client), and only ENTER_COMBAT and END_COMBAT are ever constructed. The ENTITY_DIED branch of the client handler is dead code in vanilla 1.8.9.

Exploit surface

readPacketData dispatches on a VarInt enum; an out-of-range value deserializes to null (readEnumValue returns null past the last ordinal) and the handler's event comparisons then NPE. The death message is read as a length-prefixed UTF-8 string capped at 32767 bytes, not a chat component, so no JSON component parsing happens here. END_COMBAT writes the tracked entity ID as a plain 4-byte int while ENTITY_DIED writes the killer as a VarInt and the victim as an int: the mixed widths are a known 1.8 protocol quirk.

Server-Side Handling

EntityPlayerMP.func_152111_bt and func_152112_bu wrap the combat tag transitions and send the packet with the current CombatTracker; END_COMBAT fills the duration from CombatTracker.func_180134_f and the tracked entity ID from func_94550_c. Player deaths do not produce this packet: onDeath routes the death message through ServerConfigurationManager chat broadcast, so the ENTITY_DIED variant is only reachable from plugin or modded servers that construct it directly.

Protocol Analysis

Event enum is a VarInt (readEnumValue). END_COMBAT: duration VarInt plus tracked entity ID as a full int. ENTITY_DIED: killer entity ID as VarInt, victim as int, then a String (not IChatComponent, despite the metadata table) capped at 32767 bytes. ENTER_COMBAT carries no payload. readEnumValue returns null for out-of-range values, which reaches the handler as a null eventType.

Anti-Cheat Landscape

Anti-cheats do not use S42 for validation: it is clientbound, and combat tag state is tracked server-side from attack packets (C02) and damage events. Server plugins that expose combat tags rely on ENTER_COMBAT and END_COMBAT, not on client acknowledgements, so there is nothing to spoof or cancel from the client.

implementation Implementation Cases

Combat tag transitions from the server's CombatTracker. ENTER_COMBAT and END_COMBAT are the only variants the vanilla server constructs; ENTITY_DIED exists on the wire but is dead code in vanilla 1.8.9, which is why none of the 8 clients hooks it. Client-side the handler only feeds Twitch streaming metadata.

anticheat Anti-Cheat Checks

The combat event packet carries combat tag transitions: enter combat, end combat, and entity died. Server-side anticheats do not use it for reach or killaura validation, because combat state is tracked from attack packets, but two anticheats consume it for state: Grim reads the death combat event to track whether the client's death screen is showing, which anchors its respawn-alive check, and Intave registers a packet reader that exposes the two entity id fields for substitution. Artemis and Negativity only name the packet in registries.

Respawn alive / death screen state (Grim BadPacketsM) (GrimAnticheat-Grim)

Flag a PERFORM_RESPAWN status request sent while the player is alive and no death screen is showing.

BadPacketsM listens on both directions. On the server side it wraps DEATH_COMBAT_EVENT and COMBAT_EVENT (ENTITY_DEAD) for the player's own entity id and, transaction-sandwiched, marks the menu state from showsDeathScreen. On the client side, a PERFORM_RESPAWN action while the compensated self is not dead and no menu is recorded flags the player. Change-game-state win events and respawns grant short exemptions for the client's own menu toggling.

Detects: Respawn-while-alive exploits, death-screen spoofing, and clients that send respawn without the server having announced their death.

Source: GrimAnticheat-Grim, common/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java

Variations: No other anticheat in the corpus runs a death-state check keyed to this packet; Negativity and Artemis only register the packet name.
Combat event reader (Intave) (intave-intave)

Expose the combat event packet's two integer entity fields to Intave's packet pipeline so they can be read or substituted.

CombatEventReader is registered in PacketReaders for COMBAT_EVENT. It reads the first two integers of the packet through a substitution iterator: the iterator writes back to the same integer fields, which lets the pipeline rewrite entity references carried by combat events.

Detects: None directly; it is packet plumbing that lets entity-tracking code see and optionally rewrite the entity id fields carried by combat events.

Source: intave-intave, src/main/java/de/jpx3/intave/packet/reader/CombatEventReader.java

Variations: Artemis's PacketRepository maps SERVER_PLAY + 18 to PacketPlayServerCombatEvent and ships a marker interface, and Negativity's PacketType enum lists COMBAT_EVENT('CombatEvent'); neither runs a check on it.

Wiki Cross-Reference

VarInt enum: ENTER_COMBAT (no payload), END_COMBAT (duration VarInt in ticks plus tracked entity id), ENTITY_DIED (killer id, victim id, death message).

Vanilla 1.8.9 never sends ENTITY_DIED; player deaths broadcast via chat S02 instead. Client handler only feeds Twitch stream metadata.

MCP 1.8.9 S42PacketCombatEvent implements Packet dispatching to INetHandlerPlayClient.handleCombatEvent; wire serde is readPacketData/writePacketData via readEnumValue, readInt, readStringFromBuffer, readVarIntFromBuffer.

1.8.9 callers: EntityPlayerMP.sendEnterCombat sends new S42PacketCombatEvent (line 257): https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java

Cross-checked against minecraft.wiki (CC BY-SA 3.0) for 1.8.9 accuracy.

Vanilla Internals

Full 1.8.9 logic-class sources that send or handle this packet, stored verbatim.