ClientboundCustomChatCompletionsPacket .java

net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket (record): members: action, entries, Action, handle, STREAM_CODEC, type.

net.minecraft.network.protocol.gamerecord47 linescommon1.6 KB

Implements

API Surface (2)

PacketType<ClientboundCustomChatCompletionsPacket> type()
void handle(final ClientGamePacketListener listener)

Fields & Constants (1)

STREAM_CODEC

Same Package (197)

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ClientboundCustomChatCompletionsPacket.java47 lines · Minecraft 26.3 · verbatim
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

Decompiled Minecraft 26.3 source of ClientboundCustomChatCompletionsPacket (net/minecraft/network/protocol/game/ClientboundCustomChatCompletionsPacket.java) with Mojang official mappings, stored verbatim on the site.