mojira.dev
MC-51859

The line spacing of text within all hover tooltips is larger between the first and second lines

The Bug:

The line spacing of text within all hover tooltips is larger between the first and second lines.

Steps to Reproduce:

  1. Print some hoverable text in chat by using the command provided below.

    /tellraw @s {"text":"MC-118654","hoverEvent":{"action":"show_text","contents":"MC-118654\nMC-118654\nMC-118654\nMC-118654\nMC-118654"}}
  2. Hold your mouse cursor over the text in order for a hover tooltip to be displayed.

  3. Look at the line spacing of the text within the hover tooltip.

Observed Behavior:

The line spacing of text within all hover tooltips is larger between the first and second lines.

Expected Behavior:

The line spacing of text within all hover tooltips would be equal across all lines.

Code Analysis:

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 9

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases. If this has been done, we can reopen the issue.

Keep in mind that the "Resolved"-Status on this ticket just means "Answered", and that we are waiting for further information on whether this issue still exists or not. We will reopen it as soon as the requested information has been delivered.

Can confirm for Minecraft 1.8.1 as well as for 1.8.2-pre6. Reopen this issue please.

Confirmed for 1.8.8 and 15w31c.

Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.

This is an automated comment on any open or reopened issue with out-of-date affected versions.

The following is based on a decompiled version of MC 1.12 using MCP 9.40pre-1.

In the method net.minecraft.client.gui.GuiScreen.drawHoveringText() there is for-loop through all hover-text lines in which the game checks if itis currently processing the first line. If it is, it adds a 2px gap between the next lines. It does that because a item tooltip should have a bigger gap between its title and its lores, this shouldn't be done with all tooltips which have multiple entries though.

int i2 = y - 12;
// ...

for (int k1 = 0; k1 < textLines.size(); ++k1)
{
	String s1 = textLines.get(k1);
	this.fontRendererObj.drawStringWithShadow(s1, (float)l1, (float)i2, -1);

	// This is the if-statement adding 2px to the y-coordinates of the following lines
	if (k1 == 0)
	{
		i2 += 2;
	}

	i2 += 10;
}

There are many ways to fix this issue. One would be to add a boolean called "header" to the method arguments of drawHoveringText() and check if this boolean is set to true when the first entry is rendered. But this has of course to be decided by a Mojangsta. 🙂

This is how the player list looks like with the gap disabled/if-statement skipped.

[media]

I suspect this 2px wide gap is intended for item tooltips only, other types of tooltips shouldn't be affected by that imo.

I just checked and found out that item tooltips are indeed the reason for this if-statement.
I'll edit my comment, thanks. @unknown

Confirmed for 1.13.1.

RockGermany

Avoma

(Unassigned)

Confirmed

Platform

Low

UI

Minecraft 1.7.5, Minecraft 14w11b, Minecraft 1.8.1, Minecraft 1.8.2-pre6, Minecraft 1.8.8, ..., 24w36a, 1.21.3, 1.21.4 Pre-Release 1, 1.21.4, 1.21.6

Retrieved