ServerboundPingRequestPacket 0x26

ServerboundPingRequestPacket: Minecraft 26.3 packet (0x26 Play serverbound, 0x01 Status serverbound).

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.ping

Protocol slots (2)

IDdecStateDirectionRegistry
0x2638PLAYServerboundPingPacketTypes.SERVERBOUND_PING_REQUEST: "ping_request"
0x011STATUSServerboundPingPacketTypes.SERVERBOUND_PING_REQUEST: "ping_request"

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
timelong

Stream codec

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

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

Handling

Resolved on the ServerPingPacketListener packet-listener interface by void handlePingRequest(ServerboundPingRequestPacket serverboundpingrequestpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundPingRequestPacket.java39 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.ping;
2
3
import io.netty.buffer.ByteBuf;
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 ServerboundPingRequestPacket implements Packet<ServerPingPacketListener> {
9
	public static final StreamCodec<ByteBuf, ServerboundPingRequestPacket> STREAM_CODEC = Packet.codec(
10
		ServerboundPingRequestPacket::write, ServerboundPingRequestPacket::new
11
	);
12
	private final long time;
13
14
	public ServerboundPingRequestPacket(final long time) {
15
		this.time = time;
16
	}
17
18
	private ServerboundPingRequestPacket(final ByteBuf input) {
19
		this.time = input.readLong();
20
	}
21
22
	private void write(final ByteBuf output) {
23
		output.writeLong(this.time);
24
	}
25
26
	@Override
27
	public PacketType<ServerboundPingRequestPacket> type() {
28
		return PingPacketTypes.SERVERBOUND_PING_REQUEST;
29
	}
30
31
	public void handle(final ServerPingPacketListener listener) {
32
		listener.handlePingRequest(this);
33
	}
34
35
	public long getTime() {
36
		return this.time;
37
	}
38
}
39