Class ClientReceiveMessageEvents

java.lang.Object
net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents

public final class ClientReceiveMessageEvents extends Object
Contains client-side events triggered when receiving messages.
  • Field Details

    • ALLOW_CHAT

      public static final Event<ClientReceiveMessageEvents.AllowChat> ALLOW_CHAT
      An event triggered when the client receives a chat message, which is any message sent by a player. Mods can use this to block the message.

      If a listener returned false, the message will not be displayed, the remaining listeners will be called (if any), and CHAT_CANCELED will be triggered instead of CHAT.

    • ALLOW_GAME

      public static final Event<ClientReceiveMessageEvents.AllowGame> ALLOW_GAME
      An event triggered when the client receives a game message, which is any message sent by the server. Mods can use this to block the message or toggle overlay.

      If a listener returned false, the message will not be displayed, the remaining listeners will be called (if any), and GAME_CANCELED will be triggered instead of MODIFY_GAME.

      Overlay is whether the message will be displayed in the action bar. To toggle overlay, return false and call either LocalPlayer.sendSystemMessage(message) or LocalPlayer.sendOverlayMessage(message).

    • MODIFY_GAME

      public static final Event<ClientReceiveMessageEvents.ModifyGame> MODIFY_GAME
      An event triggered when the client receives a game message, which is any message sent by the server. Is not called when game messages are blocked. Mods can use this to modify the message. Use GAME if not modifying the message.

      Overlay is whether the message will be displayed in the action bar. Use to toggle overlay.

    • CHAT

      public static final Event<ClientReceiveMessageEvents.Chat> CHAT
      An event triggered when the client receives a chat message, which is any message sent by a player. Is not called when chat messages are blocked. Mods can use this to listen to the message.

      If mods want to modify the message, they should use ALLOW_CHAT and manually add the new message to the chat hud using ChatComponent.addPlayerMessage(Component, net.minecraft.network.chat.MessageSignature, net.minecraft.client.gui.components.GuiMessageTag)

    • GAME

      public static final Event<ClientReceiveMessageEvents.Game> GAME
      An event triggered when the client receives a game message, which is any message sent by the server. Is not called when game messages are blocked. Mods can use this to listen to the message.

      Overlay is whether the message will be displayed in the action bar. Use to toggle overlay.

    • CHAT_CANCELED

      public static final Event<ClientReceiveMessageEvents.ChatCanceled> CHAT_CANCELED
      An event triggered when receiving a chat message is canceled with ALLOW_CHAT.
    • GAME_CANCELED

      public static final Event<ClientReceiveMessageEvents.GameCanceled> GAME_CANCELED
      An event triggered when receiving a game message is canceled with ALLOW_GAME.

      Overlay is whether the message would have been displayed in the action bar.