use of net.minecraft.client.gui.ChatLine in project Hyperium by HyperiumClient.
the class HyperiumGuiNewChat method drawChat.
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();
}
}
}
use of net.minecraft.client.gui.ChatLine in project Hyperium by HyperiumClient.
the class HyperiumGuiNewChat method setChatLine.
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);
}
}
}
use of net.minecraft.client.gui.ChatLine in project ct.js by ChatTriggers.
the class ChatLib method editChat.
/**
* Edits an already sent chat message
*
* @param chatMessage the unformatted text of the message to be replaced
* @param toReplace the new message to be put in replace of the old one
*/
public static void editChat(String chatMessage, String toReplace, boolean once) {
List<ChatLine> drawnChatLines = ReflectionHelper.getPrivateValue(GuiNewChat.class, Client.getChatGUI(), "drawnChatLines", "field_146252_h");
List<ChatLine> chatLines = ReflectionHelper.getPrivateValue(GuiNewChat.class, Client.getChatGUI(), "chatLines", "field_146252_h");
ChatComponentText cct = new ChatComponentText(addColor(toReplace));
for (ChatLine chatLine : drawnChatLines) {
if (removeFormatting(chatLine.getChatComponent().getUnformattedText()).equals(chatMessage)) {
ReflectionHelper.setPrivateValue(ChatLine.class, chatLine, cct, "lineString", "field_74541_b");
if (once)
break;
}
}
for (ChatLine chatLine : chatLines) {
if (removeFormatting(chatLine.getChatComponent().getUnformattedText()).equals(chatMessage)) {
ReflectionHelper.setPrivateValue(ChatLine.class, chatLine, cct, "lineString", "field_74541_b");
if (once)
break;
}
}
}
Aggregations