ClientboundContainerSetDataPacket 0x13

ClientboundContainerSetDataPacket: Minecraft 26.3 packet (0x13 Play clientbound). Wire name 'container_set_data', fields: containerId, id, value, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x1319PLAYClientboundGamePacketTypes.CLIENTBOUND_CONTAINER_SET_DATA: "container_set_data"

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

FieldType
containerIdint
idint
valueint

Stream codec

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

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleContainerSetData(ClientboundContainerSetDataPacket clientboundcontainersetdatapacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundContainerSetDataPacket.java55 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
8
public class ClientboundContainerSetDataPacket implements Packet<ClientGamePacketListener> {
9
	public static final StreamCodec<FriendlyByteBuf, ClientboundContainerSetDataPacket> STREAM_CODEC = Packet.codec(
10
		ClientboundContainerSetDataPacket::write, ClientboundContainerSetDataPacket::new
11
	);
12
	private final int containerId;
13
	private final int id;
14
	private final int value;
15
16
	public ClientboundContainerSetDataPacket(final int containerId, final int id, final int value) {
17
		this.containerId = containerId;
18
		this.id = id;
19
		this.value = value;
20
	}
21
22
	private ClientboundContainerSetDataPacket(final FriendlyByteBuf input) {
23
		this.containerId = input.readContainerId();
24
		this.id = input.readShort();
25
		this.value = input.readShort();
26
	}
27
28
	private void write(final FriendlyByteBuf output) {
29
		output.writeContainerId(this.containerId);
30
		output.writeShort(this.id);
31
		output.writeShort(this.value);
32
	}
33
34
	@Override
35
	public PacketType<ClientboundContainerSetDataPacket> type() {
36
		return GamePacketTypes.CLIENTBOUND_CONTAINER_SET_DATA;
37
	}
38
39
	public void handle(final ClientGamePacketListener listener) {
40
		listener.handleContainerSetData(this);
41
	}
42
43
	public int getContainerId() {
44
		return this.containerId;
45
	}
46
47
	public int getId() {
48
		return this.id;
49
	}
50
51
	public int getValue() {
52
		return this.value;
53
	}
54
}
55