mojira.dev
MC-11654

The text of things fall out of the picture

when you mouse over an item / server status keep the text falls outside image

Linked issues

Attachments

Comments 10

Please do not mark issues as private, unless your bug report is a security issue containing information that may compromise your server/client.

You can either turn down the GUI scale or get a bigger screen. It's not Minecraft's fault.

Actually, this is Minecraft's fault, as long as the minecraft window is large enough to contain that tooltip at some position.

The same thing (without the bug) can be seen e.g. with the browser tooltip on the "Views"-button of this JIRA page. Move the browser window to rightmost edge of display and notice how the tooltip is shifted to left to avoid going out of the display. If the window is not far enough to right, the tooltip will happily cross over the window border (since it is rendered by the OS). (These behaviors at least with Chrome on Windows 7; if getting different results, blame the maker of the OS and/or browser).

Minecraft can not provide tooltips that extend out of its window as easily (if at all), but it could still shift the tooltip to left (when necessary) in order to keep it fully in view.

(Will this be yet another issue I have to provide the code fix for?)

Edit: the code already has the proper handling for vertical case on item stacks, but not for horizontal, and nothing for the inventory tab tooltips.

Well, then, I guess it's a feature request.

Fix

GuiContainer

protected void drawItemStackTooltip(ItemStack par1ItemStack, int par2, int par3) {
            ...
            //if (this.guiTop + y + contentHeight + 6 > this.height) {
            //    y = this.height - contentHeight - this.guiTop - 6;
            //}
            x = clampXToView(x, contentWidth, this.guiLeft);
            y = clampYToView(y, contentHeight, this.guiTop);
            ...
    }

    protected void drawCreativeTabHoveringText(String tooltipText, int x, int y) {
        ...
        byte contentHeight = 8;
        // ADDED:
        x = clampXToView(x, contentWidth, 0);
        y = clampYToView(y, contentHeight, 0);
        ...
    }

    // ADDED METHODS:
    private int clampXToView(int x, int textWidth, int xFix) {
        if (xFix + x + textWidth + 6 > this.width) {
            x = this.width - textWidth - xFix - 6;
        }
        return x;
    }

    private int clampYToView(int y, int textHeight, int yFix) {
        if (yFix + y + textHeight + 6 > this.height) {
            y = this.height - textHeight - yFix - 6;
        }
        return y;
    }

Tested on 1.4.7 and works. It is a bit naive, as it does not check for the case where the text is too wide to fit in the window, in which case it would be better to let it clip on the right side. Now it clips on the left side, cutting the usually more important text from the start. However, that situation would be really rare, and the code for that case is also easy to add (though I leave that as an exercise for Mojang).

Note also the variables 'xFix' and 'yFix'. They are needed because the tooltip methods are called with different coordinate offsets. No idea why, but so it is.

There might be other GUI elements around that might benefit from the same change...

(P.S. It is often faster to make the fix than create a well-written feature request, let alone trying to keep it bumped up on the forums 😛)

is it a bug or not?

Nah its not a bug anymore! KILLSED IT!

Grum, the bug Kilser!

bug

Erik Broes

Plausible

Minecraft 1.5

Minecraft 1.5.1

Retrieved