ClientboundPlayerCombatKillPacket 0x45

ClientboundPlayerCombatKillPacket: Minecraft 26.3 packet (0x45 Play clientbound). Wire name 'player_combat_kill', fields: playerId, message, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x4569PLAYClientboundGamePacketTypes.CLIENTBOUND_PLAYER_COMBAT_KILL: "player_combat_kill"

Packet ids are positional: the id is the index of the addPacket call in the protocol builder (see ProtocolInfoBuilder.listPackets). Ids change between game versions.

Wire fields (2)

FieldType
playerIdint
messageComponent

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, ClientboundPlayerCombatKillPacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.VAR_INT, ClientboundPlayerCombatKillPacket::playerId, Component

Modern packets serialize through StreamCodecs instead of read/write methods.

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handlePlayerCombatKill(ClientboundPlayerCombatKillPacket clientboundplayercombatkillpacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundPlayerCombatKillPacket.java34 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.RegistryFriendlyByteBuf;
4
import net.minecraft.network.chat.Component;
5
import net.minecraft.network.chat.ComponentSerialization;
6
import net.minecraft.network.codec.ByteBufCodecs;
7
import net.minecraft.network.codec.StreamCodec;
8
import net.minecraft.network.protocol.Packet;
9
import net.minecraft.network.protocol.PacketType;
10
11
public record ClientboundPlayerCombatKillPacket(int playerId, Component message) implements Packet<ClientGamePacketListener> {
12
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundPlayerCombatKillPacket> STREAM_CODEC = StreamCodec.composite(
13
		ByteBufCodecs.VAR_INT,
14
		ClientboundPlayerCombatKillPacket::playerId,
15
		ComponentSerialization.TRUSTED_STREAM_CODEC,
16
		ClientboundPlayerCombatKillPacket::message,
17
		ClientboundPlayerCombatKillPacket::new
18
	);
19
20
	@Override
21
	public PacketType<ClientboundPlayerCombatKillPacket> type() {
22
		return GamePacketTypes.CLIENTBOUND_PLAYER_COMBAT_KILL;
23
	}
24
25
	public void handle(final ClientGamePacketListener listener) {
26
		listener.handlePlayerCombatKill(this);
27
	}
28
29
	@Override
30
	public boolean isSkippable() {
31
		return true;
32
	}
33
}
34