mojira.dev
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.

Linked issues

Comments 13

Can confirm for 1.12 and 1.11.2 client.

How do you send that chat packet? I'm curious.
Also, confirmed in 1.12, when failed to place a command block on height level 256.

How do you send that chat packet? I'm curious.

That requires a modified or otherwise custom server (which is the situation where this first was encountered – for the protocol documentation on wiki.vg); it's the situation where I first heard of this behavior, and then I went back and traced it to where a packet like that is sent in vanilla.

3 more comments

Seems to be fixed in 1.16.2; could someone else please confirm this?

Tested colored text component with SPacketChat. Fixed in 1.16.2

Cannot reproduce on the current release.

I did some research when I had to figure out when this bug was fixed, and figured out that it was fixed in 20w17a for 1.16.0!

I assume that they just forgot to mention this as fixed as the same snapshot added font and hex color support to components and they likely just fixed the bug while adding that

pokechu22

(Unassigned)

Confirmed

(Unassigned)

action-bar, chat, json, packets, title

Minecraft 1.12, Minecraft 17w31a, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 1.12.2 Pre-Release 1, ..., Minecraft 1.14 Pre-Release 1, Minecraft 1.14, 1.14.4, 19w41a, 1.15 Pre-release 6

Retrieved