ClientboundSetCursorItemPacket 0x62

ClientboundSetCursorItemPacket: Minecraft 26.3 packet (0x62 Play clientbound). Wire name 'set_cursor_item', fields: contents, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x6298PLAYClientboundGamePacketTypes.CLIENTBOUND_SET_CURSOR_ITEM: "set_cursor_item"

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

FieldType
contentsItemStack

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, ClientboundSetCursorItemPacket> STREAM_CODEC = StreamCodec.composite( ItemStack.OPTIONAL_STREAM_CODEC, ClientboundSetCursorItemPacket::contents, Clien

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleSetCursorItem(ClientboundSetCursorItemPacket clientboundsetcursoritempacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundSetCursorItemPacket.java23 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.StreamCodec;
5
import net.minecraft.network.protocol.Packet;
6
import net.minecraft.network.protocol.PacketType;
7
import net.minecraft.world.item.ItemStack;
8
9
public record ClientboundSetCursorItemPacket(ItemStack contents) implements Packet<ClientGamePacketListener> {
10
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundSetCursorItemPacket> STREAM_CODEC = StreamCodec.composite(
11
		ItemStack.OPTIONAL_STREAM_CODEC, ClientboundSetCursorItemPacket::contents, ClientboundSetCursorItemPacket::new
12
	);
13
14
	@Override
15
	public PacketType<ClientboundSetCursorItemPacket> type() {
16
		return GamePacketTypes.CLIENTBOUND_SET_CURSOR_ITEM;
17
	}
18
19
	public void handle(final ClientGamePacketListener listener) {
20
		listener.handleSetCursorItem(this);
21
	}
22
}
23