net.minecraft.client.gui.GuiUtilRenderComponents Java Examples

The following examples show how to use net.minecraft.client.gui.GuiUtilRenderComponents. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiCustomizeWorld.java    From YUNoMakeGoodMap with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: AdvancedTextWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private void formatDisplayText() {
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    int maxTextWidthResult = maxWidthLimit == 0 ? Integer.MAX_VALUE : maxWidthLimit;
    this.displayText = displayText.stream()
        .flatMap(c -> GuiUtilRenderComponents.splitText(c, maxTextWidthResult, fontRenderer, true, true).stream())
        .collect(Collectors.toList());
}
 
Example #3
Source File: HyperiumGuiNewChat.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, int scrollPos,
                        boolean isScrolled, List<ChatLine> chatLineList, List<ChatLine> chatLines, Minecraft mc) {
    if (chatLineId != 0) {
        parent.deleteChatLine(chatLineId);
    }

    int i = MathHelper.floor_float((float) parent.getChatWidth() / parent.getChatScale());
    List<IChatComponent> list = GuiUtilRenderComponents.splitText(chatComponent, i, mc.fontRendererObj, false, false);
    boolean flag = parent.getChatOpen();

    list.forEach(ichatcomponent -> {
        if (flag && scrollPos > 0) {
            ((IMixinGuiNewChat) parent).setIsScrolled(isScrolled);
            parent.scroll(1);
        }

        chatLineList.add(0, new ChatLine(updateCounter, ichatcomponent, chatLineId));
    });

    while (chatLineList.size() > 500) {
        chatLineList.remove(chatLineList.size() - 1);
    }

    if (!displayOnly) {
        chatLines.add(0, new ChatLine(updateCounter, chatComponent, chatLineId));

        while (chatLines.size() > 500) {
            chatLines.remove(chatLines.size() - 1);
        }
    }
}