ServerboundContainerSlotStateChangedPacket 0x14

ServerboundContainerSlotStateChangedPacket: Minecraft 26.3 packet (0x14 Play serverbound).

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x1420PLAYServerboundGamePacketTypes.SERVERBOUND_CONTAINER_SLOT_STATE_CHANGED: "container_slot_state_changed"

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
slotIdint
containerIdint
newStateboolean

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ServerboundContainerSlotStateChangedPacket> STREAM_CODEC = Packet.codec( ServerboundContainerSlotStateChangedPacket::write, ServerboundContainerSlotStateChang

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleContainerSlotStateChanged(ServerboundContainerSlotStateChangedPacket serverboundcontainerslotstatechangedpacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundContainerSlotStateChangedPacket.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
8
public record ServerboundContainerSlotStateChangedPacket(int slotId, int containerId, boolean newState) implements Packet<ServerGamePacketListener> {
9
	public static final StreamCodec<FriendlyByteBuf, ServerboundContainerSlotStateChangedPacket> STREAM_CODEC = Packet.codec(
10
		ServerboundContainerSlotStateChangedPacket::write, ServerboundContainerSlotStateChangedPacket::new
11
	);
12
13
	private ServerboundContainerSlotStateChangedPacket(final FriendlyByteBuf input) {
14
		this(input.readVarInt(), input.readContainerId(), input.readBoolean());
15
	}
16
17
	private void write(final FriendlyByteBuf output) {
18
		output.writeVarInt(this.slotId);
19
		output.writeContainerId(this.containerId);
20
		output.writeBoolean(this.newState);
21
	}
22
23
	@Override
24
	public PacketType<ServerboundContainerSlotStateChangedPacket> type() {
25
		return GamePacketTypes.SERVERBOUND_CONTAINER_SLOT_STATE_CHANGED;
26
	}
27
28
	public void handle(final ServerGamePacketListener listener) {
29
		listener.handleContainerSlotStateChanged(this);
30
	}
31
}
32