Record Class MessageType

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

public record MessageType(Optional<MessageType.DisplayRule> chat, Optional<MessageType.DisplayRule> overlay, Optional<MessageType.NarrationRule> 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.
  • 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 MessageType.DisplayRule and MessageType.NarrationRule for details.

See Also:
Mappings:
Namespace Name
official rj
intermediary net/minecraft/class_2556
named net/minecraft/network/MessageType
official j
intermediary comp_792
named chat
official k
intermediary comp_793
named overlay
official l
intermediary comp_794
named narration
  • Field Details

    • chat

      private final Optional<MessageType.DisplayRule> chat
      The field for the chat record component.
    • overlay

      private final Optional<MessageType.DisplayRule> overlay
      The field for the overlay record component.
    • narration

      private final Optional<MessageType.NarrationRule> 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 Lrj;a:Lcom/mojang/serialization/Codec;
      intermediary field_39227 Lnet/minecraft/class_2556;field_39227:Lcom/mojang/serialization/Codec;
      named CODEC Lnet/minecraft/network/MessageType;CODEC:Lcom/mojang/serialization/Codec;
    • 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 b Lrj;b:Laai;
      intermediary field_11737 Lnet/minecraft/class_2556;field_11737:Lnet/minecraft/class_5321;
      named CHAT Lnet/minecraft/network/MessageType;CHAT:Lnet/minecraft/util/registry/RegistryKey;
    • SYSTEM

      public static final RegistryKey<MessageType> SYSTEM
      The registry key for the system message message type. This is also referred to as game messages. This message type does not have a decoration and its narrations will interrupt others.
      API Note:
      System messages include join/leave messages, death messages, advancement messages, and other messages that are not sent by players.
      Mappings:
      Namespace Name Mixin selector
      official c Lrj;c:Laai;
      intermediary field_11735 Lnet/minecraft/class_2556;field_11735:Lnet/minecraft/class_5321;
      named SYSTEM Lnet/minecraft/network/MessageType;SYSTEM:Lnet/minecraft/util/registry/RegistryKey;
    • GAME_INFO

      public static final RegistryKey<MessageType> GAME_INFO
      The registry key for the game info message type. This appears on the overlay only and is not narrated at all. This message type does not have a decoration.
      API Note:
      This is most often seen when the player uses a bed.
      Mappings:
      Namespace Name Mixin selector
      official d Lrj;d:Laai;
      intermediary field_11733 Lnet/minecraft/class_2556;field_11733:Lnet/minecraft/class_5321;
      named GAME_INFO Lnet/minecraft/network/MessageType;GAME_INFO: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 e Lrj;e:Laai;
      intermediary field_39228 Lnet/minecraft/class_2556;field_39228:Lnet/minecraft/class_5321;
      named SAY_COMMAND Lnet/minecraft/network/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 f Lrj;f:Laai;
      intermediary field_39229 Lnet/minecraft/class_2556;field_39229:Lnet/minecraft/class_5321;
      named MSG_COMMAND Lnet/minecraft/network/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 g Lrj;g:Laai;
      intermediary field_39230 Lnet/minecraft/class_2556;field_39230:Lnet/minecraft/class_5321;
      named TEAM_MSG_COMMAND Lnet/minecraft/network/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 h Lrj;h:Laai;
      intermediary field_39231 Lnet/minecraft/class_2556;field_39231:Lnet/minecraft/class_5321;
      named EMOTE_COMMAND Lnet/minecraft/network/MessageType;EMOTE_COMMAND:Lnet/minecraft/util/registry/RegistryKey;
    • TELLRAW_COMMAND

      public static final RegistryKey<MessageType> TELLRAW_COMMAND
      The registry key for the tellraw command message type, used by /tellraw. This message type does not have a decoration.
      Mappings:
      Namespace Name Mixin selector
      official i Lrj;i:Laai;
      intermediary field_39232 Lnet/minecraft/class_2556;field_39232:Lnet/minecraft/class_5321;
      named TELLRAW_COMMAND Lnet/minecraft/network/MessageType;TELLRAW_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 Lrj;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/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 Lrj;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/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

      Returns the value of the chat record component.
      Returns:
      the value of the chat record component
    • overlay

      public Optional<MessageType.DisplayRule> overlay()
      Returns the value of the overlay record component.
      Returns:
      the value of the overlay record component
    • narration

      public Optional<MessageType.NarrationRule> narration()
      Returns the value of the narration record component.
      Returns:
      the value of the narration record component