ClientboundSetPlayerInventoryPacket 0x6E

ClientboundSetPlayerInventoryPacket: Minecraft 26.3 packet (0x6E Play clientbound). Wire name 'set_player_inventory', fields: slot, contents, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x6E110PLAYClientboundGamePacketTypes.CLIENTBOUND_SET_PLAYER_INVENTORY: "set_player_inventory"

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
slotint
contentsItemStack

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, ClientboundSetPlayerInventoryPacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.VAR_INT, ClientboundSetPlayerInventoryPacket::slot, ItemStack

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleSetPlayerInventory(ClientboundSetPlayerInventoryPacket clientboundsetplayerinventorypacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundSetPlayerInventoryPacket.java28 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.RegistryFriendlyByteBuf;
4
import net.minecraft.network.codec.ByteBufCodecs;
5
import net.minecraft.network.codec.StreamCodec;
6
import net.minecraft.network.protocol.Packet;
7
import net.minecraft.network.protocol.PacketType;
8
import net.minecraft.world.item.ItemStack;
9
10
public record ClientboundSetPlayerInventoryPacket(int slot, ItemStack contents) implements Packet<ClientGamePacketListener> {
11
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundSetPlayerInventoryPacket> STREAM_CODEC = StreamCodec.composite(
12
		ByteBufCodecs.VAR_INT,
13
		ClientboundSetPlayerInventoryPacket::slot,
14
		ItemStack.OPTIONAL_STREAM_CODEC,
15
		ClientboundSetPlayerInventoryPacket::contents,
16
		ClientboundSetPlayerInventoryPacket::new
17
	);
18
19
	@Override
20
	public PacketType<ClientboundSetPlayerInventoryPacket> type() {
21
		return GamePacketTypes.CLIENTBOUND_SET_PLAYER_INVENTORY;
22
	}
23
24
	public void handle(final ClientGamePacketListener listener) {
25
		listener.handleSetPlayerInventory(this);
26
	}
27
}
28