Mojira Archive
MC-119145

JSON formatting in the action bar is not supported via the chat packet, breaking coloration for some messages (spectators opening loot table chests and building too high)

Chat messages in the action bar do not correctly render component-based formatting, if they are sent via the Chat packet (0x0F). However, they do work correctly if deprecated §-based formatting codes are sent within a component, or if the Title packet (0x47) is used.

Affected methods and actions

  • Anything that directly sends a chat message with type GAME_INFO
  • Anything that calls EntityPlayer.sendStatusMessage(IChatComponent, boolean) with the second parameter set to true (both serverside and clientside)
  • Anything that calls GuiIngame.setOverlayMessage(IChatComponent, boolean) with the second parameter set to true.

Specifically, the following are known to have messages that are formatted, but don't display formatted:

  • Opening a chest in spectator mode
  • Building above the height limit

To reproduce in-game

  1. Create a chest with a loot table via
    /setblock ~ ~ ~ minecraft:chest{"LootTable":"minecraft:chests/simple_dungeon"}
    
  2. Switch to spectator mode
    /gamemode spectator
    
  3. Attempt to open the chest
    → Note that the message that appears above the hotbar is white, not red

To directly reproduce

  1. Send a chat packet (SPacketChat / 0x0F) with a payload such as {"color":"green","text":"Test"} and the position set to actionbar (ChatType.GAME_INFO / 2).
    → Observe that the message appears white

Cause

GuiIngame.setOverlayMessage(IChatComponent, boolean) uses component.getUnformattedText to get the text to display when it should use getFormattedText. (The method in question is on line 1107 of the actual source).

This does not affect the title packet because that method retrieves the formatted text and then uses GuiIngame.setOverlayMessage(String, boolean) with it.