ClientboundStoreCookiePacket 0x0B

ClientboundStoreCookiePacket: Minecraft 26.3 packet (0x0B Configuration clientbound, 0x7A Play clientbound).

Minecraft 26.3ConfigurationClientboundnet.minecraft.network.protocol.common

Protocol slots (2)

IDdecStateDirectionRegistry
0x0B11CONFIGURATIONClientboundCommonPacketTypes.CLIENTBOUND_STORE_COOKIE: "store_cookie"
0x7A122PLAYClientboundCommonPacketTypes.CLIENTBOUND_STORE_COOKIE: "store_cookie"

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
keyIdentifier
payloadbyte[]

Fields are the components of the packet record.

Stream codec

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

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

Handling

Resolved on the ClientCommonPacketListener packet-listener interface by void handleStoreCookie(ClientboundStoreCookiePacket clientboundstorecookiepacket). The implementation in the game is ClientCommonPacketListenerImpl.

Full Source

ClientboundStoreCookiePacket.java36 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.common;
2
3
import io.netty.buffer.ByteBuf;
4
import net.minecraft.network.FriendlyByteBuf;
5
import net.minecraft.network.codec.ByteBufCodecs;
6
import net.minecraft.network.codec.StreamCodec;
7
import net.minecraft.network.protocol.Packet;
8
import net.minecraft.network.protocol.PacketType;
9
import net.minecraft.resources.Identifier;
10
11
public record ClientboundStoreCookiePacket(Identifier key, byte[] payload) implements Packet<ClientCommonPacketListener> {
12
	public static final StreamCodec<FriendlyByteBuf, ClientboundStoreCookiePacket> STREAM_CODEC = Packet.codec(
13
		ClientboundStoreCookiePacket::write, ClientboundStoreCookiePacket::new
14
	);
15
	private static final int MAX_PAYLOAD_SIZE = 5120;
16
	public static final StreamCodec<ByteBuf, byte[]> PAYLOAD_STREAM_CODEC = ByteBufCodecs.byteArray(5120);
17
18
	private ClientboundStoreCookiePacket(final FriendlyByteBuf input) {
19
		this(input.readIdentifier(), PAYLOAD_STREAM_CODEC.decode(input));
20
	}
21
22
	private void write(final FriendlyByteBuf output) {
23
		output.writeIdentifier(this.key);
24
		PAYLOAD_STREAM_CODEC.encode(output, this.payload);
25
	}
26
27
	@Override
28
	public PacketType<ClientboundStoreCookiePacket> type() {
29
		return CommonPacketTypes.CLIENTBOUND_STORE_COOKIE;
30
	}
31
32
	public void handle(final ClientCommonPacketListener listener) {
33
		listener.handleStoreCookie(this);
34
	}
35
}
36