ClientboundCustomChatCompletionsPacket 0x17

ClientboundCustomChatCompletionsPacket: Minecraft 26.3 packet (0x17 Play clientbound). Wire name 'custom_chat_completions', fields: action, entries

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x1723PLAYClientboundGamePacketTypes.CLIENTBOUND_CUSTOM_CHAT_COMPLETIONS: "custom_chat_completions"

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
actionClientboundCustomChatCompletionsPacket.Action
entriesList<String>

Fields are the components of the packet record.

Stream codec

static final StreamCodec<ByteBuf, ClientboundCustomChatCompletionsPacket> STREAM_CODEC = StreamCodec.composite( ClientboundCustomChatCompletionsPacket.Action.STREAM_CODEC, ClientboundCustomChatComplet

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleCustomChatCompletions(ClientboundCustomChatCompletionsPacket clientboundcustomchatcompletionspacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundCustomChatCompletionsPacket.java47 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import io.netty.buffer.ByteBuf;
4
import java.util.List;
5
import java.util.function.IntFunction;
6
import net.minecraft.network.codec.ByteBufCodecs;
7
import net.minecraft.network.codec.StreamCodec;
8
import net.minecraft.network.protocol.Packet;
9
import net.minecraft.network.protocol.PacketType;
10
import net.minecraft.util.ByIdMap;
11
12
public record ClientboundCustomChatCompletionsPacket(ClientboundCustomChatCompletionsPacket.Action action, List<String> entries)
13
	implements Packet<ClientGamePacketListener> {
14
	public static final StreamCodec<ByteBuf, ClientboundCustomChatCompletionsPacket> STREAM_CODEC = StreamCodec.composite(
15
		ClientboundCustomChatCompletionsPacket.Action.STREAM_CODEC,
16
		ClientboundCustomChatCompletionsPacket::action,
17
		ByteBufCodecs.STRING_UTF8.apply(ByteBufCodecs.list()),
18
		ClientboundCustomChatCompletionsPacket::entries,
19
		ClientboundCustomChatCompletionsPacket::new
20
	);
21
22
	@Override
23
	public PacketType<ClientboundCustomChatCompletionsPacket> type() {
24
		return GamePacketTypes.CLIENTBOUND_CUSTOM_CHAT_COMPLETIONS;
25
	}
26
27
	public void handle(final ClientGamePacketListener listener) {
28
		listener.handleCustomChatCompletions(this);
29
	}
30
31
	public enum Action {
32
		ADD(0),
33
		REMOVE(1),
34
		SET(2);
35
36
		private static final IntFunction<ClientboundCustomChatCompletionsPacket.Action> BY_ID = ByIdMap.continuous(
37
			a -> a.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO
38
		);
39
		public static final StreamCodec<ByteBuf, ClientboundCustomChatCompletionsPacket.Action> STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, a -> a.id);
40
		private final int id;
41
42
		Action(final int id) {
43
			this.id = id;
44
		}
45
	}
46
}
47