0x42 S42PacketCombatEvent
Server sends combat-related events: enter combat, end combat, entity dead with death message.
Published 2026-06-18 · Updated 2026-10-14
Fields
| Field | Type | Description |
|---|---|---|
| event | Enum | ENTER_COMBAT, END_COMBAT, ENTITY_DIED |
| duration | VarInt | For END_COMBAT: duration in ticks |
| playerID | int | For ENTITY_DIED: victim entity ID |
| entityID | int | For ENTITY_DIED: killer entity ID |
| message | IChatComponent | For ENTITY_DIED: death message |
Wire Encoding
| Field | Type | Notes |
|---|---|---|
| Event | VarInt Enum | 0=enter,1=end,2=dead |
| Duration (if end) | VarInt | |
| Player (if dead) | int | |
| Entity (if dead) | int | |
| Message (if dead) | Chat Component |
MCP References
NetHandlerPlayClient.handleCombatEvent()Handler Interface
INetHandlerPlayClientVanilla Source
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 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.
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.
// ===== FILE: GrimAnticheat-Grim, common/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java =====
package ac.grim.grimac.checks.impl.badpackets;
import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.PreViaPacketReceiveListener;
import ac.grim.grimac.checks.type.PreViaPacketSendListener;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.event.PacketSendEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.player.Combat;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerChangeGameState;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerCombatEvent;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDeathCombatEvent;
@CheckData(name = "BadPacketsM", stableKey = "grim.badpackets.respawn_alive", description = "Tried to respawn while alive", experimental = true)
public class BadPacketsM extends Check implements PreViaPacketReceiveListener, PreViaPacketSendListener {
public BadPacketsM(final GrimPlayer player) {
super(player);
}
// not a boolean because the server could send packets that cause
// the client to send a respawn packet before it receives the first
private int exempt;
private boolean menu;
@Override
public void onPreViaPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() != PacketType.Play.Client.CLIENT_STATUS
|| new WrapperPlayClientClientStatus(event).getAction() != WrapperPlayClientClientStatus.Action.PERFORM_RESPAWN) {
return;
}
if (exempt > 0) {
exempt--;
return;
}
if (!player.compensatedEntities.self.isDead && !menu) {
flag(); // don't cancel in case of a false positive
}
// the client closes the menu and reopens it if dead
menu = player.compensatedEntities.self.isDead && player.packetStateData.showsDeathScreen;
}
@Override
public void onPreViaPacketSend(PacketSendEvent event) {
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
return;
}
if (event.getPacketType() == PacketType.Play.Server.CHANGE_GAME_STATE) {
WrapperPlayServerChangeGameState packet = new WrapperPlayServerChangeGameState(event);
if (packet.getReason() != WrapperPlayServerChangeGameState.Reason.WIN_GAME) return;
if (packet.getValue() != 0 && packet.getValue() != 1) {
return; // client ignores this
}
player.sendTransaction();
player.addRealTimeTaskNow(() -> {
// we COULD get a DEATH_COMBAT_EVENT/COMBAT_EVENT while the credits are rolling, (IF packet.getValue == 1)
// but this can only cause at most one false negative (for each of this packet sent)
exempt++;
menu = false;
});
}
if (event.getPacketType() == PacketType.Play.Server.DEATH_COMBAT_EVENT
&& new WrapperPlayServerDeathCombatEvent(event).getPlayerId() == player.entityID) {
player.sendTransaction();
player.addRealTimeTaskNow(this::onDeathCombatEvent);
}
if (event.getPacketType() == PacketType.Play.Server.COMBAT_EVENT) {
WrapperPlayServerCombatEvent packet = new WrapperPlayServerCombatEvent(event);
if (packet.getCombat() == Combat.ENTITY_DEAD && packet.getPlayerId() == player.entityID) {
player.sendTransaction();
player.addRealTimeTaskNow(this::onDeathCombatEvent);
}
}
}
private void onDeathCombatEvent() {
if (player.packetStateData.showsDeathScreen) {
menu = true;
} else {
exempt++;
}
}
public void onRespawn() {
menu = false; // the client closes any open screens on respawn
}
// the menu is actually kept when the player's health is set to >0
public void onDeath() {
if (player.packetStateData.showsDeathScreen) {
menu = true;
}
}
}
// NOTE (AI): The check is marked experimental and flags without cancelling to avoid false positives. On 1.8 the death screen is implied by the death combat event itself; the change-game-state and respawn hooks cover the 1.19+ death screen toggle.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.
// ===== FILE: intave-intave, src/main/java/de/jpx3/intave/packet/reader/CombatEventReader.java =====
package de.jpx3.intave.packet.reader;
import org.jetbrains.annotations.NotNull;
public final class CombatEventReader extends AbstractPacketReader implements EntityIterable{
public int firstEntityId() {
return packet().getIntegers().read(0);
}
public int secondEntityId() {
return packet().getIntegers().read(1);
}
private int slot = 0;
@Override
public @NotNull SubstitutionIterator<Integer> iterator() {
slot = 0;
return STATIC_ITERATOR;
}
private final SubstitutionIterator<Integer> STATIC_ITERATOR = new SubstitutionIterator<Integer>() {
@Override
public void set(Integer integer) {
if (slot == 1) {
packet().getIntegers().write(0, integer);
} else if (slot == 2) {
packet().getIntegers().write(1, integer);
}
}
@Override
public boolean hasNext() {
return slot < 2;
}
@Override
public Integer next() {
return packet().getIntegers().read(slot++);
}
};
}
// NOTE (AI): The reader implements EntityIterable, so the two ids are treated as substitution targets: any rewrite writes back into the raw packet integers, keeping the packet valid on the wire.Related Packets
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
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.