| 1 | package net.minecraft.network.protocol.game;
|
| 2 |
|
| 3 | import java.util.Optional;
|
| 4 | import java.util.UUID;
|
| 5 | import net.minecraft.core.UUIDUtil;
|
| 6 | import net.minecraft.network.RegistryFriendlyByteBuf;
|
| 7 | import net.minecraft.network.chat.ChatType;
|
| 8 | import net.minecraft.network.chat.Component;
|
| 9 | import net.minecraft.network.chat.ComponentSerialization;
|
| 10 | import net.minecraft.network.chat.FilterMask;
|
| 11 | import net.minecraft.network.chat.MessageSignature;
|
| 12 | import net.minecraft.network.chat.SignedMessageBody;
|
| 13 | import net.minecraft.network.codec.ByteBufCodecs;
|
| 14 | import net.minecraft.network.codec.StreamCodec;
|
| 15 | import net.minecraft.network.protocol.Packet;
|
| 16 | import net.minecraft.network.protocol.PacketType;
|
| 17 |
|
| 18 | public record ClientboundPlayerChatPacket(
|
| 19 | int globalIndex,
|
| 20 | UUID sender,
|
| 21 | int index,
|
| 22 | Optional<MessageSignature> signature,
|
| 23 | SignedMessageBody.Packed body,
|
| 24 | Optional<Component> unsignedContent,
|
| 25 | FilterMask filterMask,
|
| 26 | ChatType.Bound chatType
|
| 27 | ) implements Packet<ClientGamePacketListener> {
|
| 28 | public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundPlayerChatPacket> STREAM_CODEC = StreamCodec.composite(
|
| 29 | ByteBufCodecs.VAR_INT,
|
| 30 | ClientboundPlayerChatPacket::globalIndex,
|
| 31 | UUIDUtil.STREAM_CODEC,
|
| 32 | ClientboundPlayerChatPacket::sender,
|
| 33 | ByteBufCodecs.VAR_INT,
|
| 34 | ClientboundPlayerChatPacket::index,
|
| 35 | MessageSignature.STREAM_CODEC.apply(ByteBufCodecs::optional),
|
| 36 | ClientboundPlayerChatPacket::signature,
|
| 37 | SignedMessageBody.Packed.STREAM_CODEC,
|
| 38 | ClientboundPlayerChatPacket::body,
|
| 39 | ComponentSerialization.TRUSTED_OPTIONAL_STREAM_CODEC,
|
| 40 | ClientboundPlayerChatPacket::unsignedContent,
|
| 41 | FilterMask.STREAM_CODEC,
|
| 42 | ClientboundPlayerChatPacket::filterMask,
|
| 43 | ChatType.Bound.STREAM_CODEC,
|
| 44 | ClientboundPlayerChatPacket::chatType,
|
| 45 | ClientboundPlayerChatPacket::new
|
| 46 | );
|
| 47 |
|
| 48 | @Override
|
| 49 | public PacketType<ClientboundPlayerChatPacket> type() {
|
| 50 | return GamePacketTypes.CLIENTBOUND_PLAYER_CHAT;
|
| 51 | }
|
| 52 |
|
| 53 | public void handle(final ClientGamePacketListener listener) {
|
| 54 | listener.handlePlayerChat(this);
|
| 55 | }
|
| 56 |
|
| 57 | @Override
|
| 58 | public boolean isSkippable() {
|
| 59 | return true;
|
| 60 | }
|
| 61 | }
|
| 62 |
|