Java 类net.minecraft.client.gui.GuiUtilRenderComponents 实例源码

项目:CustomWorldGen    文件:GuiModList.java   
private List<ITextComponent> resizeContent(List<String> lines)
{
    List<ITextComponent> ret = new ArrayList<ITextComponent>();
    for (String line : lines)
    {
        if (line == null)
        {
            ret.add(null);
            continue;
        }

        ITextComponent chat = ForgeHooks.newChatWithLinks(line, false);
        ret.addAll(GuiUtilRenderComponents.splitText(chat, this.listWidth-8, GuiModList.this.fontRendererObj, false, true));
    }
    return ret;
}
项目:Easy-Editors    文件:CommandHelpManager.java   
@Override
public void draw(int mouseX, int mouseY, int y, int virtualWidth) {
    List<ITextComponent> lines = GuiUtilRenderComponents.splitText(text, virtualWidth - 20, fontRenderer, false,
            false);

    int runningY = y;

    for (ITextComponent line : lines) {
        String strLine = line.getFormattedText();
        int halfLineWidth = fontRenderer.getStringWidth(strLine) / 2;
        int lineLeft = virtualWidth / 2 - halfLineWidth;
        fontRenderer.drawString(strLine, lineLeft, runningY, 0xffffff);

        runningY += fontRenderer.FONT_HEIGHT;
    }

    ITextComponent hoveredComponent = getHoveredComponent(virtualWidth, y, mouseX, mouseY);
    if (hoveredComponent != null)
        GeneralUtils.handleHoverEvent(hoveredComponent.getStyle().getHoverEvent(), mouseX, mouseY);

}
项目:Easy-Editors    文件:CommandHelpManager.java   
private ITextComponent getHoveredComponent(int virtualWidth, int y, int mouseX, int mouseY) {
    List<ITextComponent> lines = GuiUtilRenderComponents.splitText(text, virtualWidth - 20, fontRenderer, false,
            false);

    for (ITextComponent line : lines) {
        String strLine = line.getFormattedText();
        int halfLineWidth = fontRenderer.getStringWidth(strLine) / 2;
        int lineLeft = virtualWidth / 2 - halfLineWidth;
        int lineRight = virtualWidth / 2 + halfLineWidth;

        if (mouseY >= y && mouseY < y + fontRenderer.FONT_HEIGHT && mouseX >= lineLeft && mouseX < lineRight) {
            ITextComponent hoveredComponent = null;
            for (ITextComponent sibling : line) {
                hoveredComponent = sibling;
                lineLeft += fontRenderer.getStringWidth(GuiUtilRenderComponents
                        .removeTextColorsIfConfigured(sibling.getUnformattedComponentText(), false));
                if (mouseX < lineLeft)
                    break;
            }
            return hoveredComponent;
        }

        y += fontRenderer.FONT_HEIGHT;
    }
    return null;
}
项目:YUNoMakeGoodMap    文件:GuiCustomizeWorld.java   
private List<ITextComponent> resizeContent(List<String> lines)
{
    List<ITextComponent> ret = new ArrayList<ITextComponent>();
    for (String line : lines)
    {
        if (line == null)
        {
            ret.add(null);
            continue;
        }

        ITextComponent chat = ForgeHooks.newChatWithLinks(line, false);
        ret.addAll(GuiUtilRenderComponents.splitText(chat, this.listWidth-8, GuiCustomizeWorld.this.fontRenderer, false, true));
    }
    return ret;
}
项目:Easy-Editors    文件:CommandHelpManager.java   
@Override
public int getHeight(int virtualWidth) {
    return GuiUtilRenderComponents.splitText(text, virtualWidth - 20, fontRenderer, false, false).size()
            * fontRenderer.FONT_HEIGHT;
}
项目:TabbyChat-2    文件:ChatTextUtils.java   
public static List<ITextComponent> split(ITextComponent chat, int width) {
    FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    return GuiUtilRenderComponents.splitText(chat, width, fr, false, false);
}