net.minecraft.client.gui.ChatLine Java Examples

The following examples show how to use net.minecraft.client.gui.ChatLine. 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: 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);
        }
    }
}
 
Example #2
Source File: ConsoleGui.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public void refreshChat() {
    this.drawnChatLines.clear();
    this.resetScroll();

    for (int i = this.chatLines.size() - 1; i >= 0; --i) {
        ChatLine chatline = this.chatLines.get(i);
        this.setChatLine(chatline.func_151461_a(), chatline.getChatLineID(), chatline.getUpdatedCounter(), true);
    }
}
 
Example #3
Source File: HyperiumGuiNewChat.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void drawChat(int updateCounter, List<ChatLine> drawnChatLines, int scrollPos, boolean isScrolled, Minecraft mc) {
    if (mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) {
        int i = parent.getLineCount();
        boolean flag = false;
        int j = 0;
        int k = drawnChatLines.size();
        float f = mc.gameSettings.chatOpacity * 0.9F + 0.1F;

        if (k > 0) {
            if (parent.getChatOpen()) flag = true;

            float f1 = parent.getChatScale();
            int l = MathHelper.ceiling_float_int((float) parent.getChatWidth() / f1);
            GlStateManager.pushMatrix();
            GlStateManager.translate(2.0F, 20.0F, 0.0F);
            GlStateManager.scale(f1, f1, 1.0F);

            for (int i1 = 0; i1 + scrollPos < drawnChatLines.size() && i1 < i; ++i1) {
                ChatLine chatline = drawnChatLines.get(i1 + scrollPos);

                if (chatline != null) {
                    int j1 = updateCounter - chatline.getUpdatedCounter();

                    if (j1 < 200 || flag) {
                        double d0 = (double) j1 / 200.0D;
                        d0 = 1.0D - d0;
                        d0 = d0 * 10.0D;
                        d0 = MathHelper.clamp_double(d0, 0.0D, 1.0D);
                        d0 = d0 * d0;
                        int l1 = (int) (255.0D * d0);

                        if (flag) l1 = 255;

                        l1 = (int) ((float) l1 * f);
                        ++j;

                        if (l1 > 3) {
                            int i2 = 0;
                            int j2 = -i1 * 9;
                            if (!Settings.FASTCHAT)
                                Gui.drawRect(i2, j2 - 9, i2 + l + 4, j2, l1 / 2 << 24);
                            String s = chatline.getChatComponent().getFormattedText();
                            GlStateManager.enableBlend();
                            mc.fontRendererObj.drawStringWithShadow(s, (float) i2, (float) (j2 - 8), 16777215 + (l1 << 24));
                            GlStateManager.disableAlpha();
                            GlStateManager.disableBlend();
                        }
                    }
                }
            }

            if (flag) {
                int k2 = mc.fontRendererObj.FONT_HEIGHT;
                GlStateManager.translate(-3.0F, 0.0F, 0.0F);
                int l2 = k * k2 + k;
                int i3 = j * k2 + j;
                int j3 = scrollPos * i3 / k;
                int k1 = i3 * i3 / l2;

                if (l2 != i3) {
                    int k3 = j3 > 0 ? 170 : 96;
                    int l3 = isScrolled ? 13382451 : 3355562;
                    Gui.drawRect(0, -j3, 2, -j3 - k1, l3 + (k3 << 24));
                    Gui.drawRect(2, -j3, 1, -j3 - k1, 13421772 + (k3 << 24));
                }
            }

            GlStateManager.popMatrix();
        }
    }
}
 
Example #4
Source File: ConsoleGui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public void drawChat(int tickid) {
    if (prevWidth != this.mc.gameSettings.chatWidth) {
        prevWidth = this.mc.gameSettings.chatWidth;
        refreshChat();
    }
    int j = this.getLineCount();
    boolean flag = false;
    int k = 0;
    int l = this.drawnChatLines.size();
    float f = this.mc.gameSettings.chatOpacity * 0.9F + 0.1F;

    if (l > 0) {
        if (this.getChatOpen()) {
            flag = true;
        }

        float f1 = this.getChatScale();
        int i1 = MathHelper.ceiling_float_int(this.getChatWidth() / f1);
        GL11.glPushMatrix();
        ScaledResolution get = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
        GL11.glTranslatef(get.getScaledWidth() - 6 - getChatWidth(), get.getScaledHeight() - 28, 0.0F);
        GL11.glScalef(f1, f1, 1.0F);
        int j1;
        int k1;
        int i2;

        for (j1 = 0; j1 + this.scrollPos < this.drawnChatLines.size() && j1 < j; ++j1) {
            ChatLine chatline = this.drawnChatLines.get(j1 + this.scrollPos);

            if (chatline != null) {
                k1 = tickid - chatline.getUpdatedCounter();

                if (k1 < 200 || flag) {
                    double d0 = k1 / 200.0D;
                    d0 = 1.0D - d0;
                    d0 *= 10.0D;

                    if (d0 < 0.0D) {
                        d0 = 0.0D;
                    }

                    if (d0 > 1.0D) {
                        d0 = 1.0D;
                    }

                    d0 *= d0;
                    i2 = (int) (255.0D * d0);

                    if (flag) {
                        i2 = 255;
                    }

                    i2 = (int) (i2 * f);
                    ++k;

                    if (i2 > 3) {
                        byte b0 = 0;
                        int j2 = -j1 * 9;
                        drawRect(b0, j2 - 9, b0 + i1 + 4, j2, i2 / 2 << 24);
                        GL11.glEnable(GL11.GL_BLEND); // FORGE: BugFix MC-36812 Chat Opacity Broken in 1.7.x
                        String s = chatline.func_151461_a().getFormattedText();
                        this.mc.fontRenderer.drawStringWithShadow(s, b0, j2 - 8, 16777215 + (i2 << 24));
                        GL11.glDisable(GL11.GL_ALPHA_TEST);
                    }
                }
            }
        }

        if (flag) {
            j1 = this.mc.fontRenderer.FONT_HEIGHT;
            GL11.glTranslatef(-3.0F, 0.0F, 0.0F);
            int k2 = l * j1 + l;
            k1 = k * j1 + k;
            int l2 = this.scrollPos * k1 / l;
            int l1 = k1 * k1 / k2;

            if (k2 != k1) {
                i2 = l2 > 0 ? 170 : 96;
                int i3 = this.isScrolled ? 13382451 : 3355562;
                drawRect(0, -l2, 2, -l2 - l1, i3 + (i2 << 24));
                drawRect(2, -l2, 1, -l2 - l1, 13421772 + (i2 << 24));
            }
        }

        GL11.glPopMatrix();
    }
}
 
Example #5
Source File: ConsoleGui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IChatComponent getChatComponent(int mouseX, int mouseY) {
    if (!this.getChatOpen()) {
        return null;
    } else {
        ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
        int k = scaledresolution.getScaleFactor();
        float f = this.getChatScale();
        int l = mouseX / k - 3;
        int i1 = mouseY / k - 27;
        l = MathHelper.floor_float(l / f);
        i1 = MathHelper.floor_float(i1 / f);

        if (l >= 0 && i1 >= 0) {
            int j1 = Math.min(this.getLineCount(), this.drawnChatLines.size());

            if (l <= MathHelper.floor_float(this.getChatWidth() / this.getChatScale()) && i1 < this.mc.fontRenderer.FONT_HEIGHT * j1 + j1) {
                int k1 = i1 / this.mc.fontRenderer.FONT_HEIGHT + this.scrollPos;

                if (k1 >= 0 && k1 < this.drawnChatLines.size()) {
                    ChatLine chatline = this.drawnChatLines.get(k1);
                    int l1 = 0;

                    for (Object iChatComponent : chatline.func_151461_a()) {
                        if (iChatComponent instanceof ChatComponentText) {
                            l1 += this.mc.fontRenderer.getStringWidth(this.func_146235_b(((ChatComponentText) iChatComponent).getChatComponentText_TextValue()));

                            if (l1 > l) {
                                return (IChatComponent) iChatComponent;
                            }
                        }
                    }
                }

                return null;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
}
 
Example #6
Source File: WChatInputEvent.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
public WChatInputEvent(ITextComponent component, List<ChatLine> chatLines)
{
	this.component = component;
	this.chatLines = chatLines;
}
 
Example #7
Source File: WChatInputEvent.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
public List<ChatLine> getChatLines()
{
	return chatLines;
}
 
Example #8
Source File: IMixinGuiNewChat.java    From Hyperium with GNU Lesser General Public License v3.0 votes vote down vote up
@Accessor List<ChatLine> getChatLines(); 
Example #9
Source File: IMixinGuiNewChat.java    From Hyperium with GNU Lesser General Public License v3.0 votes vote down vote up
@Accessor List<ChatLine> getDrawnChatLines();