ServerboundPongPacket 0x05

ServerboundPongPacket: Minecraft 26.3 packet (0x05 Configuration serverbound, 0x2D Play serverbound).

Minecraft 26.3ConfigurationServerboundnet.minecraft.network.protocol.common

Protocol slots (2)

IDdecStateDirectionRegistry
0x055CONFIGURATIONServerboundCommonPacketTypes.SERVERBOUND_PONG: "pong"
0x2D45PLAYServerboundCommonPacketTypes.SERVERBOUND_PONG: "pong"

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, ServerboundPongPacket> STREAM_CODEC = Packet.codec(ServerboundPongPacket::write, ServerboundPongPacket::new);

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

Handling

Resolved on the ServerCommonPacketListener packet-listener interface by void handlePong(ServerboundPongPacket serverboundpongpacket). The implementation in the game is ServerCommonPacketListenerImpl.

Full Source

ServerboundPongPacket.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 ServerboundPongPacket implements Packet<ServerCommonPacketListener> {
9
	public static final StreamCodec<FriendlyByteBuf, ServerboundPongPacket> STREAM_CODEC = Packet.codec(ServerboundPongPacket::write, ServerboundPongPacket::new);
10
	private final int id;
11
12
	public ServerboundPongPacket(final int id) {
13
		this.id = id;
14
	}
15
16
	private ServerboundPongPacket(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<ServerboundPongPacket> type() {
26
		return CommonPacketTypes.SERVERBOUND_PONG;
27
	}
28
29
	public void handle(final ServerCommonPacketListener listener) {
30
		listener.handlePong(this);
31
	}
32
33
	public int getId() {
34
		return this.id;
35
	}
36
}
37