ServerboundCustomClickActionPacket 0x08

ServerboundCustomClickActionPacket: Minecraft 26.3 packet (0x08 Configuration serverbound, 0x44 Play serverbound).

Minecraft 26.3ConfigurationServerboundnet.minecraft.network.protocol.common

Protocol slots (2)

IDdecStateDirectionRegistry
0x088CONFIGURATIONServerboundCommonPacketTypes.SERVERBOUND_CUSTOM_CLICK_ACTION: "custom_click_action"
0x4468PLAYServerboundCommonPacketTypes.SERVERBOUND_CUSTOM_CLICK_ACTION: "custom_click_action"

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
idIdentifier
payloadOptional<Tag>

Fields are the components of the packet record.

Stream codec

static final StreamCodec<ByteBuf, Optional<Tag>> UNTRUSTED_TAG_CODEC = ByteBufCodecs.optionalTagCodec(() -> new NbtAccounter(32768L, 16)) .apply(ByteBufCodecs.lengthPrefixed(65536));

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

Handling

Resolved on the ServerCommonPacketListener packet-listener interface by void handleCustomClickAction(ServerboundCustomClickActionPacket serverboundcustomclickactionpacket). The implementation in the game is ServerCommonPacketListenerImpl.

Full Source

ServerboundCustomClickActionPacket.java33 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.common;
2
3
import io.netty.buffer.ByteBuf;
4
import java.util.Optional;
5
import net.minecraft.nbt.NbtAccounter;
6
import net.minecraft.nbt.Tag;
7
import net.minecraft.network.codec.ByteBufCodecs;
8
import net.minecraft.network.codec.StreamCodec;
9
import net.minecraft.network.protocol.Packet;
10
import net.minecraft.network.protocol.PacketType;
11
import net.minecraft.resources.Identifier;
12
13
public record ServerboundCustomClickActionPacket(Identifier id, Optional<Tag> payload) implements Packet<ServerCommonPacketListener> {
14
	private static final StreamCodec<ByteBuf, Optional<Tag>> UNTRUSTED_TAG_CODEC = ByteBufCodecs.optionalTagCodec(() -> new NbtAccounter(32768L, 16))
15
		.apply(ByteBufCodecs.lengthPrefixed(65536));
16
	public static final StreamCodec<ByteBuf, ServerboundCustomClickActionPacket> STREAM_CODEC = StreamCodec.composite(
17
		Identifier.STREAM_CODEC,
18
		ServerboundCustomClickActionPacket::id,
19
		UNTRUSTED_TAG_CODEC,
20
		ServerboundCustomClickActionPacket::payload,
21
		ServerboundCustomClickActionPacket::new
22
	);
23
24
	@Override
25
	public PacketType<ServerboundCustomClickActionPacket> type() {
26
		return CommonPacketTypes.SERVERBOUND_CUSTOM_CLICK_ACTION;
27
	}
28
29
	public void handle(final ServerCommonPacketListener listener) {
30
		listener.handleCustomClickAction(this);
31
	}
32
}
33