mojira.dev
MC-112765

hoverEvent JSON with specified color does not share among new lines

The bug

When you do a tellraw command with a hoverEvent and you specify a color (such as specified below), the color only works along the first line.

/tellraw @p [{"text":"Hover!","hoverEvent":{"action":"show_text","value":[{"text":"Green text\nNot green text","color":"green"}]}}]

When hovered, should show

Green Text
Not green text

instead of

Green Text
Not green text

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

This happens because the method net.minecraft.client.gui.GuiScreen.handleComponentHover(ITextComponent, int, int) just splits the text at line breaks and then renders each line separately. Therefor the second line has no formatting anymore. Instead the method net.minecraft.client.gui.GuiUtilRenderComponents.splitText(ITextComponent, int, FontRenderer, boolean, boolean) could be used.

Comments 1

I added panels for the expected and actual hover text.

Feel free to remove them if you think they are unnecessary or don't look good.

TheMuffinPony

Nathan Adams

Confirmed

color, formatting, hoverEvent, line-break, tellraw

Minecraft 1.11.2, Minecraft 17w06a

Minecraft 1.12 Pre-Release 3

Retrieved