Record Class ChatMessageS2CPacket

java.lang.Object
java.lang.Record
net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket
Record Components:
signedContent -
unsignedContent -
typeId -
sender -
timestamp -
saltSignature -
All Implemented Interfaces:
Packet<ClientPlayPacketListener>

public record ChatMessageS2CPacket(Text signedContent, Optional<Text> unsignedContent, int typeId, MessageSender sender, Instant timestamp, NetworkEncryptionUtils.SignatureData saltSignature) extends Record implements Packet<ClientPlayPacketListener>
A packet used to send a chat message to the clients.

The content is not wrapped in any way (e.g. by chat.type.text text); the raw message content is sent to the clients, and they will wrap it. To register custom wrapping behaviors, check MessageType.register(java.lang.String).

Messages that took more than TIME_TO_LIVE to reach the clients are considered expired. This is measured from the time the client sent the chat message to the server. Note that unlike ChatMessageC2SPacket expired messages are not discarded by the clients; they instead log a warning.

Chat messages have signatures. It is possible to use a bogus signature - such as MessageSignature.none() - to send a chat message; however if the signature is invalid (e.g. because the text's content differs from the one sent by the client, or because the passed signature is invalid) the client will log a warning. See MessageSignature.updateSignature(net.minecraft.network.encryption.SignatureUpdatable.SignatureUpdater, net.minecraft.text.Text, java.util.UUID, java.time.Instant, long) for how the message is signed.

See Also:
Mappings:
Namespace Name
official uo
intermediary net/minecraft/class_7438
named net/minecraft/network/packet/s2c/play/ChatMessageS2CPacket
official a
intermediary comp_833
named signedContent
official b
intermediary comp_834
named unsignedContent
official c
intermediary comp_806
named typeId
official d
intermediary comp_760
named sender
official e
intermediary comp_761
named timestamp
official f
intermediary comp_762
named saltSignature
  • Field Details

    • signedContent

      private final Text signedContent
      The field for the signedContent record component.
    • unsignedContent

      private final Optional<Text> unsignedContent
      The field for the unsignedContent record component.
    • typeId

      private final int typeId
      The field for the typeId record component.
    • sender

      private final MessageSender sender
      The field for the sender record component.
    • timestamp

      private final Instant timestamp
      The field for the timestamp record component.
    • saltSignature

      private final NetworkEncryptionUtils.SignatureData saltSignature
      The field for the saltSignature record component.
    • TIME_TO_LIVE

      private static final Duration TIME_TO_LIVE
      Mappings:
      Namespace Name Mixin selector
      official g Luo;g:Ljava/time/Duration;
      intermediary field_39085 Lnet/minecraft/class_7438;field_39085:Ljava/time/Duration;
      named TIME_TO_LIVE Lnet/minecraft/network/packet/s2c/play/ChatMessageS2CPacket;TIME_TO_LIVE:Ljava/time/Duration;
  • Constructor Details

    • ChatMessageS2CPacket

      public ChatMessageS2CPacket(PacketByteBuf buf)
      Mappings:
      Namespace Name Mixin selector
      official <init> Luo;<init>(Lqx;)V
      intermediary <init> Lnet/minecraft/class_7438;<init>(Lnet/minecraft/class_2540;)V
      named <init> Lnet/minecraft/network/packet/s2c/play/ChatMessageS2CPacket;<init>(Lnet/minecraft/network/PacketByteBuf;)V
    • ChatMessageS2CPacket

      public ChatMessageS2CPacket(Text text, Optional<Text> optional, int int2, MessageSender messageSender, Instant instant, NetworkEncryptionUtils.SignatureData signatureData)
  • Method Details

    • write

      public void write(PacketByteBuf buf)
      Specified by:
      write in interface Packet<ClientPlayPacketListener>
      Mappings:
      Namespace Name Mixin selector
      official a Lso;a(Lqx;)V
      intermediary method_11052 Lnet/minecraft/class_2596;method_11052(Lnet/minecraft/class_2540;)V
      named write Lnet/minecraft/network/Packet;write(Lnet/minecraft/network/PacketByteBuf;)V
    • apply

      public void apply(ClientPlayPacketListener clientPlayPacketListener)
      Specified by:
      apply in interface Packet<ClientPlayPacketListener>
      Mappings:
      Namespace Name Mixin selector
      official a Luo;a(Lsr;)V
      intermediary method_43629 Lnet/minecraft/class_7438;method_43629(Lnet/minecraft/class_2602;)V
      named apply Lnet/minecraft/network/packet/s2c/play/ChatMessageS2CPacket;apply(Lnet/minecraft/network/listener/ClientPlayPacketListener;)V
    • isWritingErrorSkippable

      public boolean isWritingErrorSkippable()
      Returns whether a throwable in writing of this packet allows the connection to simply skip the packet's sending than disconnecting.
      Specified by:
      isWritingErrorSkippable in interface Packet<ClientPlayPacketListener>
      Mappings:
      Namespace Name Mixin selector
      official a Lso;a()Z
      intermediary method_11051 Lnet/minecraft/class_2596;method_11051()Z
      named isWritingErrorSkippable Lnet/minecraft/network/Packet;isWritingErrorSkippable()Z
    • getSignedMessage

      public SignedMessage getSignedMessage()
      Mappings:
      Namespace Name Mixin selector
      official b Luo;b()Lru;
      intermediary method_43885 Lnet/minecraft/class_7438;method_43885()Lnet/minecraft/class_7471;
      named getSignedMessage Lnet/minecraft/network/packet/s2c/play/ChatMessageS2CPacket;getSignedMessage()Lnet/minecraft/network/message/SignedMessage;
    • getExpiryTime

      private Instant getExpiryTime()
      Returns when the message is considered expired.
      Returns:
      when the message is considered expired
      Mappings:
      Namespace Name Mixin selector
      official i Luo;i()Ljava/time/Instant;
      intermediary method_43630 Lnet/minecraft/class_7438;method_43630()Ljava/time/Instant;
      named getExpiryTime Lnet/minecraft/network/packet/s2c/play/ChatMessageS2CPacket;getExpiryTime()Ljava/time/Instant;
    • isExpired

      public boolean isExpired(Instant currentTime)
      Returns whether the message is considered expired.
      Returns:
      whether the message is considered expired
      Mappings:
      Namespace Name Mixin selector
      official a Luo;a(Ljava/time/Instant;)Z
      intermediary method_43628 Lnet/minecraft/class_7438;method_43628(Ljava/time/Instant;)Z
      named isExpired Lnet/minecraft/network/packet/s2c/play/ChatMessageS2CPacket;isExpired(Ljava/time/Instant;)Z
    • getMessageType

      public MessageType getMessageType(Registry<MessageType> registry)
      Returns the message type of the chat message.
      Returns:
      the message type of the chat message
      Throws:
      NullPointerException - when the type ID is invalid (due to unsynced registry, etc)
      Mappings:
      Namespace Name Mixin selector
      official a Luo;a(Lhm;)Lrj;
      intermediary method_43884 Lnet/minecraft/class_7438;method_43884(Lnet/minecraft/class_2378;)Lnet/minecraft/class_2556;
      named getMessageType Lnet/minecraft/network/packet/s2c/play/ChatMessageS2CPacket;getMessageType(Lnet/minecraft/util/registry/Registry;)Lnet/minecraft/network/message/MessageType;
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object object)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      object - the object with which to compare
      Returns:
      true if this object is the same as the object argument; false otherwise.
    • signedContent

      public Text signedContent()
      Returns the value of the signedContent record component.
      Returns:
      the value of the signedContent record component
    • unsignedContent

      public Optional<Text> unsignedContent()
      Returns the value of the unsignedContent record component.
      Returns:
      the value of the unsignedContent record component
    • typeId

      public int typeId()
      Returns the value of the typeId record component.
      Returns:
      the value of the typeId record component
    • sender

      public MessageSender sender()
      Returns the value of the sender record component.
      Returns:
      the value of the sender record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • saltSignature

      public NetworkEncryptionUtils.SignatureData saltSignature()
      Returns the value of the saltSignature record component.
      Returns:
      the value of the saltSignature record component