Example usage for net.minecraftforge.fml.client.config GuiUtils drawHoveringText

List of usage examples for net.minecraftforge.fml.client.config GuiUtils drawHoveringText

Introduction

In this page you can find the example usage for net.minecraftforge.fml.client.config GuiUtils drawHoveringText.

Prototype

public static void drawHoveringText(@Nonnull final ItemStack stack, List<String> textLines, int mouseX,
        int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font) 

Source Link

Document

Use this version if calling from somewhere where ItemStack context is available.

Usage

From source file:mod.rankshank.arbitraria.client.ui.componenet.ComponentContainer.java

@Override
public void textPass(float zLevel, float partialTicks, FontRenderer font) {
    for (ItemGrid grid : grids) {
        int y = grid.yLoc + 10;
        for (Slot[] row : grid.slots) {
            int x = grid.xLoc + 10;
            for (Slot slot : row) {
                if (slot.getHasStack() && slot.getStack().getCount() > 1) {
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(0, 0, zLevel + 350);
                    String cnt = String.valueOf(slot.getStack().getCount());
                    font.drawString(cnt, cnt.length() == 1 ? x + 2 : x - (cnt.length() - 1) * 2, y, 0xFFFFFF,
                            true);// w  ww  . j av a2  s  .co m
                    GlStateManager.popMatrix();
                }
                x += 18;
            }
            y += 18;

        }
    }
    if (!hover.isEmpty()) {
        FontRenderer rep = hover.getItem().getFontRenderer(hover);
        toolTip.clear();
        toolTip.addAll(hover.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips));
        for (int i = 0; i < toolTip.size(); ++i)
            if (i == 0)
                toolTip.set(i, hover.getRarity().rarityColor + toolTip.get(i));
            else
                toolTip.set(i, TextFormatting.GRAY + toolTip.get(i));
        GuiUtils.preItemToolTip(hover);
        GuiUtils.drawHoveringText(hover, toolTip, cacheMouseX, cacheMouseY, screen.width, screen.height, -1,
                rep == null ? font : rep);
        GuiUtils.postItemToolTip();
    }
}