ClientboundPlayerChatPacket.java

net.minecraft.network.protocol.game.ClientboundPlayerChatPacket

信息

  • 全限定名:net.minecraft.network.protocol.game.ClientboundPlayerChatPacket
  • 类型:public record
  • 包:net.minecraft.network.protocol.game
  • 源码路径:src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerChatPacket.java
  • 起始行号:L17
  • 实现:Packet
  • 职责:

    TODO

字段/常量

  • STREAM_CODEC
    • 类型: StreamCodec<RegistryFriendlyByteBuf,ClientboundPlayerChatPacket>
    • 修饰符: public static final
    • 源码定位: L27
    • 说明:

      TODO

内部类/嵌套类型

构造器

private ClientboundPlayerChatPacket(RegistryFriendlyByteBuf input) @ L31

  • 构造器名:ClientboundPlayerChatPacket
  • 源码定位:L31
  • 修饰符:private

参数:

  • input: RegistryFriendlyByteBuf

说明:

TODO

方法

下面的方法块按源码顺序生成。

private void write(RegistryFriendlyByteBuf output) @ L44

  • 方法名:write
  • 源码定位:L44
  • 返回类型:void
  • 修饰符:private

参数:

  • output: RegistryFriendlyByteBuf

说明:

TODO

public PacketType<ClientboundPlayerChatPacket> type() @ L55

  • 方法名:type
  • 源码定位:L55
  • 返回类型:PacketType
  • 修饰符:public

参数:

说明:

TODO

public void handle(ClientGamePacketListener listener) @ L60

  • 方法名:handle
  • 源码定位:L60
  • 返回类型:void
  • 修饰符:public

参数:

  • listener: ClientGamePacketListener

说明:

TODO

public boolean isSkippable() @ L64

  • 方法名:isSkippable
  • 源码定位:L64
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

代码

public record ClientboundPlayerChatPacket(
    int globalIndex,
    UUID sender,
    int index,
    @Nullable MessageSignature signature,
    SignedMessageBody.Packed body,
    @Nullable Component unsignedContent,
    FilterMask filterMask,
    ChatType.Bound chatType
) implements Packet<ClientGamePacketListener> {
    public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundPlayerChatPacket> STREAM_CODEC = Packet.codec(
        ClientboundPlayerChatPacket::write, ClientboundPlayerChatPacket::new
    );
 
    private ClientboundPlayerChatPacket(RegistryFriendlyByteBuf input) {
        this(
            input.readVarInt(),
            input.readUUID(),
            input.readVarInt(),
            input.readNullable(MessageSignature::read),
            new SignedMessageBody.Packed(input),
            FriendlyByteBuf.readNullable(input, ComponentSerialization.TRUSTED_STREAM_CODEC),
            FilterMask.read(input),
            ChatType.Bound.STREAM_CODEC.decode(input)
        );
    }
 
    private void write(RegistryFriendlyByteBuf output) {
        output.writeVarInt(this.globalIndex);
        output.writeUUID(this.sender);
        output.writeVarInt(this.index);
        output.writeNullable(this.signature, MessageSignature::write);
        this.body.write(output);
        FriendlyByteBuf.writeNullable(output, this.unsignedContent, ComponentSerialization.TRUSTED_STREAM_CODEC);
        FilterMask.write(output, this.filterMask);
        ChatType.Bound.STREAM_CODEC.encode(output, this.chatType);
    }
 
    @Override
    public PacketType<ClientboundPlayerChatPacket> type() {
        return GamePacketTypes.CLIENTBOUND_PLAYER_CHAT;
    }
 
    public void handle(ClientGamePacketListener listener) {
        listener.handlePlayerChat(this);
    }
 
    @Override
    public boolean isSkippable() {
        return true;
    }
}

引用的其他类