ClientboundDisguisedChatPacket 0x21

ClientboundDisguisedChatPacket: Minecraft 26.3 packet (0x21 Play clientbound). Wire name 'disguised_chat', fields: message, chatType, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x2133PLAYClientboundGamePacketTypes.CLIENTBOUND_DISGUISED_CHAT: "disguised_chat"

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
messageComponent
chatTypeChatType.Bound

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, ClientboundDisguisedChatPacket> STREAM_CODEC = StreamCodec.composite( ComponentSerialization.TRUSTED_STREAM_CODEC, ClientboundDisguisedChatPacket::mes

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleDisguisedChat(ClientboundDisguisedChatPacket clientbounddisguisedchatpacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundDisguisedChatPacket.java34 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.chat.ChatType;
5
import net.minecraft.network.chat.Component;
6
import net.minecraft.network.chat.ComponentSerialization;
7
import net.minecraft.network.codec.StreamCodec;
8
import net.minecraft.network.protocol.Packet;
9
import net.minecraft.network.protocol.PacketType;
10
11
public record ClientboundDisguisedChatPacket(Component message, ChatType.Bound chatType) implements Packet<ClientGamePacketListener> {
12
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundDisguisedChatPacket> STREAM_CODEC = StreamCodec.composite(
13
		ComponentSerialization.TRUSTED_STREAM_CODEC,
14
		ClientboundDisguisedChatPacket::message,
15
		ChatType.Bound.STREAM_CODEC,
16
		ClientboundDisguisedChatPacket::chatType,
17
		ClientboundDisguisedChatPacket::new
18
	);
19
20
	@Override
21
	public PacketType<ClientboundDisguisedChatPacket> type() {
22
		return GamePacketTypes.CLIENTBOUND_DISGUISED_CHAT;
23
	}
24
25
	public void handle(final ClientGamePacketListener listener) {
26
		listener.handleDisguisedChat(this);
27
	}
28
29
	@Override
30
	public boolean isSkippable() {
31
		return true;
32
	}
33
}
34