ClientboundPingPacket 0x05

ClientboundPingPacket: Minecraft 26.3 packet (0x05 Configuration clientbound, 0x3E Play clientbound).

Minecraft 26.3ConfigurationClientboundnet.minecraft.network.protocol.common

Protocol slots (2)

IDdecStateDirectionRegistry
0x055CONFIGURATIONClientboundCommonPacketTypes.CLIENTBOUND_PING: "ping"
0x3E62PLAYClientboundCommonPacketTypes.CLIENTBOUND_PING: "ping"

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 (1)

FieldType
idint

Stream codec

static final StreamCodec<FriendlyByteBuf, ClientboundPingPacket> STREAM_CODEC = Packet.codec(ClientboundPingPacket::write, ClientboundPingPacket::new);

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

Handling

Resolved on the ClientCommonPacketListener packet-listener interface by void handlePing(ClientboundPingPacket clientboundpingpacket). The implementation in the game is ClientCommonPacketListenerImpl.

Full Source

ClientboundPingPacket.java37 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.common;
2
3
import net.minecraft.network.FriendlyByteBuf;
4
import net.minecraft.network.codec.StreamCodec;
5
import net.minecraft.network.protocol.Packet;
6
import net.minecraft.network.protocol.PacketType;
7
8
public class ClientboundPingPacket implements Packet<ClientCommonPacketListener> {
9
	public static final StreamCodec<FriendlyByteBuf, ClientboundPingPacket> STREAM_CODEC = Packet.codec(ClientboundPingPacket::write, ClientboundPingPacket::new);
10
	private final int id;
11
12
	public ClientboundPingPacket(final int id) {
13
		this.id = id;
14
	}
15
16
	private ClientboundPingPacket(final FriendlyByteBuf input) {
17
		this.id = input.readInt();
18
	}
19
20
	private void write(final FriendlyByteBuf output) {
21
		output.writeInt(this.id);
22
	}
23
24
	@Override
25
	public PacketType<ClientboundPingPacket> type() {
26
		return CommonPacketTypes.CLIENTBOUND_PING;
27
	}
28
29
	public void handle(final ClientCommonPacketListener listener) {
30
		listener.handlePing(this);
31
	}
32
33
	public int getId() {
34
		return this.id;
35
	}
36
}
37