Search in sources :

Example 1 with IContainerTooltipHandler

use of codechicken.nei.guihook.IContainerTooltipHandler in project LogisticsPipes by RS485.

the class NEIProxy method renderItemToolTip.

@Override
@SideOnly(Side.CLIENT)
@SneakyThrows({ NoSuchFieldException.class, IllegalAccessException.class })
public boolean renderItemToolTip(int mousex, int mousey, List<String> msg, EnumChatFormatting rarityColor, ItemStack stack) {
    if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
        return false;
    }
    GuiContainer window = (GuiContainer) Minecraft.getMinecraft().currentScreen;
    List<String> tooltip = new LinkedList<String>();
    FontRenderer font = GuiDraw.fontRenderer;
    if (GuiContainerManager.shouldShowTooltip(window)) {
        font = GuiContainerManager.getFontRenderer(stack);
        if (stack != null) {
            tooltip = msg;
        }
        for (IContainerTooltipHandler handler : (List<IContainerTooltipHandler>) ReflectionHelper.getPrivateField(List.class, GuiContainerManager.class, "instanceTooltipHandlers", GuiContainerManager.getManager())) {
            tooltip = handler.handleItemTooltip(window, stack, mousex, mousey, tooltip);
        }
    }
    if (tooltip.size() > 0) {
        tooltip.set(0, tooltip.get(0) + "§h");
    }
    GuiDraw.drawMultilineTip(font, mousex + 12, mousey - 12, tooltip);
    return true;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) FontRenderer(net.minecraft.client.gui.FontRenderer) IContainerTooltipHandler(codechicken.nei.guihook.IContainerTooltipHandler) LinkedList(java.util.LinkedList) GuiContainerManager(codechicken.nei.guihook.GuiContainerManager) SneakyThrows(lombok.SneakyThrows) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

GuiContainerManager (codechicken.nei.guihook.GuiContainerManager)1 IContainerTooltipHandler (codechicken.nei.guihook.IContainerTooltipHandler)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 SneakyThrows (lombok.SneakyThrows)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)1