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

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

Introduction

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

Prototype

public static void preItemToolTip(@Nonnull ItemStack stack) 

Source Link

Document

Must be called from GuiScreen.renderToolTip before GuiScreen.drawHoveringText is called.

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 w  w. j  a  va2 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();
    }
}