Record Class MessageType

java.lang.Object
java.lang.Record
net.minecraft.network.message.MessageType
Record Components:
chat - the display rule for the content displayed in the chat hud, or
invalid @link
Optional#empty()
if it should not be displayed in the chat hud
narration - the narration rule for the content, or
invalid @link
Optional#empty()
if it should not be narrated

public record MessageType(Decoration chat, Decoration narration) extends Record
A message type (also known as "chat type") controls whether to display or narrate the messages sent to the clients, and if so, how. Message types are registered at BuiltinRegistries.MESSAGE_TYPE. When sending a message, the registry key of the message type can be passed to indicate which message type should be used.

Message type has three fields, all of which are optional. If the field is empty, the message is not displayed or narrated there.

  • chat controls the content displayed in the chat hud.
  • invalid @link
    #overlay
    controls the content displayed as the overlay (above the hotbar).
  • narration controls the narrated content.

The display rules and the narration rule can optionally have a "decoration", which is an instance of Decoration. Decorations are pre-defined message formatting and styling rules, which can be applied to the message to produce the displayed or narrated text. If there is no decoration, the message is used without any extra processing. See the documentation for

invalid @link
MessageType.DisplayRule
and
invalid @link
MessageType.NarrationRule
for details.
See Also:
  • invalid @see
    net.minecraft.server.PlayerManager#broadcast(Text, RegistryKey)
Mappings:
Namespace Name
official ri
intermediary net/minecraft/class_2556
named net/minecraft/network/message/MessageType
official h
intermediary comp_792
named chat
official i
intermediary comp_794
named narration
  • Field Details

    • chat

      private final Decoration chat
      The field for the chat record component.
    • narration

      private final Decoration narration
      The field for the narration record component.
    • CODEC

      public static final com.mojang.serialization.Codec<MessageType> CODEC
      Mappings:
      Namespace Name Mixin selector
      official a Lri;a:Lcom/mojang/serialization/Codec;
      intermediary field_39227 Lnet/minecraft/class_2556;field_39227:Lcom/mojang/serialization/Codec;
      named CODEC Lnet/minecraft/network/message/MessageType;CODEC:Lcom/mojang/serialization/Codec;
    • CHAT_TEXT_DECORATION

      public static final Decoration CHAT_TEXT_DECORATION
      Mappings:
      Namespace Name Mixin selector
      official b Lri;b:Lrj;
      intermediary field_39677 Lnet/minecraft/class_2556;field_39677:Lnet/minecraft/class_7463;
      named CHAT_TEXT_DECORATION Lnet/minecraft/network/message/MessageType;CHAT_TEXT_DECORATION:Lnet/minecraft/text/Decoration;
    • CHAT

      public static final RegistryKey<MessageType> CHAT
      The registry key for the message type used by chat messages. The message content is decorated using the chat.type.text text.
      Mappings:
      Namespace Name Mixin selector
      official c Lri;c:Laai;
      intermediary field_11737 Lnet/minecraft/class_2556;field_11737:Lnet/minecraft/class_5321;
      named CHAT Lnet/minecraft/network/message/MessageType;CHAT:Lnet/minecraft/util/registry/RegistryKey;
    • SAY_COMMAND

      public static final RegistryKey<MessageType> SAY_COMMAND
      The registry key for the say command message type, used by /say. The message content is decorated using the chat.type.announcement text.
      Mappings:
      Namespace Name Mixin selector
      official d Lri;d:Laai;
      intermediary field_39228 Lnet/minecraft/class_2556;field_39228:Lnet/minecraft/class_5321;
      named SAY_COMMAND Lnet/minecraft/network/message/MessageType;SAY_COMMAND:Lnet/minecraft/util/registry/RegistryKey;
    • MSG_COMMAND

      public static final RegistryKey<MessageType> MSG_COMMAND
      The registry key for the message command message type, used by /msg. The message content is decorated using the commands.message.display.incoming text, and the text is italicized and colored gray.
      Mappings:
      Namespace Name Mixin selector
      official e Lri;e:Laai;
      intermediary field_39229 Lnet/minecraft/class_2556;field_39229:Lnet/minecraft/class_5321;
      named MSG_COMMAND Lnet/minecraft/network/message/MessageType;MSG_COMMAND:Lnet/minecraft/util/registry/RegistryKey;
    • TEAM_MSG_COMMAND

      public static final RegistryKey<MessageType> TEAM_MSG_COMMAND
      The registry key for the team message command message type, used by /teammsg. The message content is decorated using the chat.type.team.text text.
      Mappings:
      Namespace Name Mixin selector
      official f Lri;f:Laai;
      intermediary field_39230 Lnet/minecraft/class_2556;field_39230:Lnet/minecraft/class_5321;
      named TEAM_MSG_COMMAND Lnet/minecraft/network/message/MessageType;TEAM_MSG_COMMAND:Lnet/minecraft/util/registry/RegistryKey;
    • EMOTE_COMMAND

      public static final RegistryKey<MessageType> EMOTE_COMMAND
      The registry key for the emote command message type, used by /me. The message content is decorated using the chat.type.emote text.
      Mappings:
      Namespace Name Mixin selector
      official g Lri;g:Laai;
      intermediary field_39231 Lnet/minecraft/class_2556;field_39231:Lnet/minecraft/class_5321;
      named EMOTE_COMMAND Lnet/minecraft/network/message/MessageType;EMOTE_COMMAND:Lnet/minecraft/util/registry/RegistryKey;
  • Constructor Details

  • Method Details

    • register

      private static RegistryKey<MessageType> register(String id)
      Mappings:
      Namespace Name Mixin selector
      official a Lri;a(Ljava/lang/String;)Laai;
      intermediary method_43845 Lnet/minecraft/class_2556;method_43845(Ljava/lang/String;)Lnet/minecraft/class_5321;
      named register Lnet/minecraft/network/message/MessageType;register(Ljava/lang/String;)Lnet/minecraft/util/registry/RegistryKey;
    • initialize

      public static RegistryEntry<MessageType> initialize(Registry<MessageType> registry)
      Mappings:
      Namespace Name Mixin selector
      official a Lri;a(Lhm;)Lhc;
      intermediary method_43844 Lnet/minecraft/class_2556;method_43844(Lnet/minecraft/class_2378;)Lnet/minecraft/class_6880;
      named initialize Lnet/minecraft/network/message/MessageType;initialize(Lnet/minecraft/util/registry/Registry;)Lnet/minecraft/util/registry/RegistryEntry;
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • chat

      public Decoration chat()
      Returns the value of the chat record component.
      Returns:
      the value of the chat record component
    • narration

      public Decoration narration()
      Returns the value of the narration record component.
      Returns:
      the value of the narration record component