ClientboundDebugSamplePacket 0x1E

ClientboundDebugSamplePacket: Minecraft 26.3 packet (0x1E Play clientbound). Wire name 'debug_sample', fields: sample, debugSampleType, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x1E30PLAYClientboundGamePacketTypes.CLIENTBOUND_DEBUG_SAMPLE: "debug_sample"

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
samplelong[]
debugSampleTypeRemoteDebugSampleType

Fields are the components of the packet record.

Stream codec

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

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleDebugSample(ClientboundDebugSamplePacket clientbounddebugsamplepacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundDebugSamplePacket.java32 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
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
import net.minecraft.util.debugchart.RemoteDebugSampleType;
8
9
public record ClientboundDebugSamplePacket(long[] sample, RemoteDebugSampleType debugSampleType) implements Packet<ClientGamePacketListener> {
10
	public static final StreamCodec<FriendlyByteBuf, ClientboundDebugSamplePacket> STREAM_CODEC = Packet.codec(
11
		ClientboundDebugSamplePacket::write, ClientboundDebugSamplePacket::new
12
	);
13
14
	private ClientboundDebugSamplePacket(final FriendlyByteBuf input) {
15
		this(input.readLongArray(), input.readEnum(RemoteDebugSampleType.class));
16
	}
17
18
	private void write(final FriendlyByteBuf output) {
19
		output.writeLongArray(this.sample);
20
		output.writeEnum(this.debugSampleType);
21
	}
22
23
	@Override
24
	public PacketType<ClientboundDebugSamplePacket> type() {
25
		return GamePacketTypes.CLIENTBOUND_DEBUG_SAMPLE;
26
	}
27
28
	public void handle(final ClientGamePacketListener listener) {
29
		listener.handleDebugSample(this);
30
	}
31
}
32