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

项目:SignPicture    文件:CustomChatRender.java   
public void applyChatLines(final @Nonnull List<ChatLine> lines) {
    if (!lines.equals(this.linescache)) {
        this.pendentryids.clear();
        int updateCounterCreated = -1;
        int chatLineID = -1;
        {
            final Set<EntryId> addedentries = Sets.newHashSet();
            for (final ChatLine line : lines) {
                updateCounterCreated = line.getUpdatedCounter();
                chatLineID = line.getChatLineID();
                final IChatComponent cc = line.func_151461_a();
                final List<ClickEvent> clinks = getLinksFromChat(cc);
                for (final ClickEvent clink : clinks) {
                    final EntryId entryid = new EntryIdBuilder().setURI(clink.getValue()).build();
                    if (!addedentries.contains(entryid))
                        this.pendentryids.add(entryid);
                    addedentries.add(entryid);
                }
            }
        }
        this.updateCounterCreated = updateCounterCreated;
        this.chatLineID = chatLineID;
    }
    this.linescache = lines;
}
项目:Providence    文件:CommandManager.java   
@SuppressWarnings("unchecked")
@Command({"clear", "cc"})
public void clearChat() {
    GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
    List<ChatLine> tempList = new ArrayList<>();
    for (ChatLine c : (ArrayList<ChatLine>) mc.ingameGUI.persistantChatGUI.field_146253_i) {
        if (c.getChatComponent().getFormattedText().contains(Client.NAME)) {
            tempList.add(c);
        }
        for (Method m : getMap().keySet()) {
            Command command = m.getAnnotation(Command.class);
            if (c.getChatComponent().getFormattedText().contains(command.value()[0]) && (c.getChatComponent().getFormattedText().contains("]") || c.getChatComponent().getFormattedText().contains("]") || c.getChatComponent().getFormattedText().contains(","))) {
                tempList.add(c);
            }
        }

    }
    mc.ingameGUI.persistantChatGUI.field_146253_i.removeAll(tempList);
}
项目:RuneCraftery    文件:GuiNewChat.java   
public ChatClickData func_73766_a(int p_73766_1_, int p_73766_2_) {
   if(!this.func_73760_d()) {
      return null;
   } else {
      ScaledResolution var3 = new ScaledResolution(this.field_73772_a.field_71474_y, this.field_73772_a.field_71443_c, this.field_73772_a.field_71440_d);
      int var4 = var3.func_78325_e();
      float var5 = this.func_96131_h();
      int var6 = p_73766_1_ / var4 - 3;
      int var7 = p_73766_2_ / var4 - 25;
      var6 = MathHelper.func_76141_d((float)var6 / var5);
      var7 = MathHelper.func_76141_d((float)var7 / var5);
      if(var6 >= 0 && var7 >= 0) {
         int var8 = Math.min(this.func_96127_i(), this.field_96134_d.size());
         if(var6 <= MathHelper.func_76141_d((float)this.func_96126_f() / this.func_96131_h()) && var7 < this.field_73772_a.field_71466_p.field_78288_b * var8 + var8) {
            int var9 = var7 / (this.field_73772_a.field_71466_p.field_78288_b + 1) + this.field_73768_d;
            return new ChatClickData(this.field_73772_a.field_71466_p, (ChatLine)this.field_96134_d.get(var9), var6, var7 - (var9 - this.field_73768_d) * this.field_73772_a.field_71466_p.field_78288_b + var9);
         } else {
            return null;
         }
      } else {
         return null;
      }
   }
}
项目:SignPicture    文件:CustomChatRender.java   
@CoreInvoke
public static int hookDrawStringWithShadow(final @Nonnull FontRenderer font, final @Nonnull String str, final int x, final int y, final int color, final @Nonnull GuiNewChat chat, final @Nonnull ChatLine chatline, final int j2, final int opacity) {
    if (chatline instanceof PicChatLine) {
        final PicChatLine cline = (PicChatLine) chatline;
        OpenGL.glPushMatrix();
        OpenGL.glTranslatef(0f, j2, 0f);
        OpenGL.glColor4i(255, 255, 255, opacity);
        cline.draw(chat, font.FONT_HEIGHT);
        OpenGL.glPopMatrix();
        WRenderer.startTexture();
    } else
        // this.mc.fontRenderer.drawStringWithShadow(s, b0, j2-8, 16777215+(i2<<24));
        font.drawStringWithShadow(str, x, y, color);
    return 0;
}
项目:EvenWurse    文件:AntiSpamMod.java   
@Override
public void onReceivedMessage(ChatInputEvent event) {
    final List<ChatLine> chatLines = event.getChatLines();
    new Thread(() -> {
        try {
            Thread.sleep(50);
            if (chatLines.size() > 1) {
                for (int i = chatLines.size() - 1; i >= 1; i--) {
                    for (int i2 = i - 1; i2 >= 0; i2--) {
                        // Fixes concurrent modification
                        if (chatLines.size() <= i) continue;

                        if (chatLines.get(i).getChatComponent().getUnformattedText()
                                .startsWith(chatLines.get(i2).getChatComponent().getUnformattedText())) {
                            if (chatLines.get(i).getChatComponent().getUnformattedText().endsWith("]") &&
                                    chatLines.get(i).getChatComponent().getUnformattedText().contains(" [x")) {
                                int numberIndex1 = chatLines.get(i).getChatComponent().getUnformattedText()
                                        .lastIndexOf(" [x") + 3;
                                int numberIndex2 =
                                        chatLines.get(i).getChatComponent().getUnformattedText().length() - 1;
                                int number = Integer.valueOf(
                                        chatLines.get(i).getChatComponent().getUnformattedText()
                                                .substring(numberIndex1, numberIndex2));
                                chatLines.get(i2).getChatComponent().appendText(" [x" + (number + 1) + "]");
                            } else {
                                chatLines.get(i2).getChatComponent().appendText(" [x2]");
                            }
                            chatLines.remove(i);
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }, "AntiSpam").start();
}
项目:mcpvp-mod    文件:ChatCTF.java   
public static void handleAll(ClientChatReceivedEvent event) {
    // Removal of messages that appear in split chat.
    for (Object chatLine : Main.secondChat.getMessages()) {

        // The chat message in the second chat.
        String oldMessage = ((ChatLine)chatLine).func_151461_a().getUnformattedText();
        if (oldMessage.equals(event.message.getUnformattedText())) {
            event.setCanceled(true);
        }
    }
}
项目:mcpvp-mod    文件:GuiSecondChat.java   
public void refreshChat()
{
    this.field_146253_i.clear();
    this.resetScroll();

    for (int i = this.chatLines.size() - 1; i >= 0; --i)
    {
        ChatLine chatline = (ChatLine)this.chatLines.get(i);
        this.func_146237_a(chatline.func_151461_a(), chatline.getChatLineID(), chatline.getUpdatedCounter(), true);
    }
}
项目:RuneCraftery    文件:GuiNewChat.java   
private void func_96129_a(String p_96129_1_, int p_96129_2_, int p_96129_3_, boolean p_96129_4_) {
   boolean var5 = this.func_73760_d();
   boolean var6 = true;
   if(p_96129_2_ != 0) {
      this.func_73759_c(p_96129_2_);
   }

   Iterator var7 = this.field_73772_a.field_71466_p.func_78271_c(p_96129_1_, MathHelper.func_76141_d((float)this.func_96126_f() / this.func_96131_h())).iterator();

   while(var7.hasNext()) {
      String var8 = (String)var7.next();
      if(var5 && this.field_73768_d > 0) {
         this.field_73769_e = true;
         this.func_73758_b(1);
      }

      if(!var6) {
         var8 = " " + var8;
      }

      var6 = false;
      this.field_96134_d.add(0, new ChatLine(p_96129_3_, var8, p_96129_2_));
   }

   while(this.field_96134_d.size() > 100) {
      this.field_96134_d.remove(this.field_96134_d.size() - 1);
   }

   if(!p_96129_4_) {
      this.field_73771_c.add(0, new ChatLine(p_96129_3_, p_96129_1_.trim(), p_96129_2_));

      while(this.field_73771_c.size() > 100) {
         this.field_73771_c.remove(this.field_73771_c.size() - 1);
      }
   }

}
项目:RuneCraftery    文件:GuiNewChat.java   
public void func_96132_b() {
   this.field_96134_d.clear();
   this.func_73764_c();

   for(int var1 = this.field_73771_c.size() - 1; var1 >= 0; --var1) {
      ChatLine var2 = (ChatLine)this.field_73771_c.get(var1);
      this.func_96129_a(var2.func_74538_a(), var2.func_74539_c(), var2.func_74540_b(), true);
   }

}
项目:RuneCraftery    文件:ChatClickData.java   
public ChatClickData(FontRenderer p_i1037_1_, ChatLine p_i1037_2_, int p_i1037_3_, int p_i1037_4_) {
   this.field_78314_b = p_i1037_1_;
   this.field_78315_c = p_i1037_2_;
   this.field_78312_d = p_i1037_3_;
   this.field_78313_e = p_i1037_4_;
   this.field_78310_f = p_i1037_1_.func_78269_a(p_i1037_2_.func_74538_a(), p_i1037_3_);
   this.field_78311_g = this.func_78307_h();
}
项目:Wurst-MC-1.12    文件:AntiSpamMod.java   
@Override
public void onReceivedMessage(ChatInputEvent event)
{
    // check if chat history is empty
    if(event.getChatLines().isEmpty())
        return;

    String newLine = event.getComponent().getUnformattedText();
    int spamCounter = 1;

    // count and remove duplicates of the new line
    for(Iterator<ChatLine> itr = event.getChatLines().iterator(); itr
        .hasNext();)
    {
        // find old lines that start with the new one
        String line = itr.next().getChatComponent().getUnformattedText();
        if(!line.startsWith(newLine))
            continue;

        // if the old line equals the new one, add 1 to the counter
        if(line.length() == newLine.length())
            spamCounter++;
        else
        {
            // if the old line equals the new one plus added text, check if
            // that text is a spam counter

            // first check if it matches " [x.*]"
            String addedText = line.substring(newLine.length());
            if(!addedText.startsWith(" [x") || !addedText.endsWith("]"))
                continue;

            // then check if the counter value is a valid number
            String oldSpamCounter =
                addedText.substring(3, addedText.length() - 1);
            if(!MiscUtils.isInteger(oldSpamCounter))
                continue;

            // if the old counter is valid, add its value to the new counter
            spamCounter += Integer.parseInt(oldSpamCounter);
        }

        // remove the old line
        itr.remove();
    }

    // if the new line exists more than once, add a spam counter to it
    if(spamCounter > 1)
        event.getComponent().appendText(" [x" + spamCounter + "]");
}
项目:Wurst-MC-1.12    文件:ChatInputEvent.java   
public ChatInputEvent(ITextComponent component, List<ChatLine> chatLines)
{
    this.component = component;
    this.chatLines = chatLines;
}
项目:Wurst-MC-1.12    文件:ChatInputEvent.java   
public List<ChatLine> getChatLines()
{
    return chatLines;
}
项目:Zombe-Modpack    文件:ZModpack.java   
/**
    Called at each new client tick
    note: used to be pingUpdateHandle()
*/
static void clientTick(EntityPlayerSP player) {
    // notify mods
    if (!initialized) return;

    try {
        // check state
        if (getPlayer() == null) return;
        if (getWorld() == null) return;
        if (getRenderer() == null) return;

        // keyboard state update
        Keys.newTick();

        // check world change
        if (PC != getPlayerController()) {
            PC = getPlayerController();
            allowCheats = true;
            allowFlying = true;
            allowNoclip = !isMultiplayer();
            chatWelcomed = !isMultiplayer();
            worldChange();
        }

        List<ChatLine> chat = getChatLines();
        if (!chatWelcomed && chat != null) { for (int line = 0; line < chat.size(); ++line) {
            String msg = ZWrapper.getChatText(chat, line);
            if (msg == null) continue;
            if (msg == chatLast) break;
            if (msg.contains("joined the game")) { chatWelcomed = true; continue; }
            if (msg.contains("\u00a7f \u00a7f \u00a71 \u00a70 \u00a72 \u00a74"))
                allowFlying = false;
            if (msg.contains("\u00a7f \u00a7f \u00a72 \u00a70 \u00a74 \u00a78"))
                allowCheats = false;
            if (msg.contains("\u00a7f \u00a7f \u00a74 \u00a70 \u00a79 \u00a76"))
                allowNoclip = allowFlying;
            if (msg.matches(".*(\\W|^)no-z-fly(\\W|$).*"))
                allowFlying = false;
            if (msg.matches(".*(\\W|^)no-z-cheat(\\W|$).*"))
                allowCheats = false;
            if (msg.matches(".*(\\W|^)z-cheat(\\W|$).*"))
                allowNoclip = allowFlying;
        }
        if (chat.size()>0) chatLast = getChatText(chat, 0);
        }

        // update logging
        if (!isInMenu() && wasKeyPressedThisTick(keyClearDisplayedError)) {
            setMessage("error", null);
        }

        // notify mods
        for (ZMod mod : zombesMods)
            try {
                mod.notifyClientTick(player);
            } catch (Exception e) {
                err("in mod \""+mod.getName()+"\": update failed",e);
            }
    } catch(Exception error) { err("error: update-handle failed", error); }

}
项目:SignPicture    文件:CustomChatRender.java   
public PicChatID(final int id, final @Nonnull List<ChatLine> lines) {
    this.id = id;
    this.lines = lines;
}
项目:SignPicture    文件:CustomChatRender.java   
@CoreInvoke
public PicChatHook(final @Nonnull List<ChatLine> chatLinesHook) {
    this.chatLinesHook = chatLinesHook;
}
项目:EvenWurse    文件:ChatInputEvent.java   
public ChatInputEvent(IChatComponent component, List<ChatLine> chatLines) {
    this.component = component;
    this.chatLines = chatLines;
}
项目:EvenWurse    文件:ChatInputEvent.java   
public List<ChatLine> getChatLines() {
    return chatLines;
}
项目:mcpvp-mod    文件:GuiSecondChat.java   
public IChatComponent func_146236_a(int p_146236_1_, int p_146236_2_)
  {
      if (!this.getChatOpen())
      {
          return null;
      }

ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
int k = scaledresolution.getScaleFactor();
float f = this.func_146244_h();
int l = p_146236_1_ / k - 3;
int i1 = p_146236_2_ / k - 27;
l = MathHelper.floor_float(l / f);
i1 = MathHelper.floor_float(i1 / f);

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

    if (l <= MathHelper.floor_float(this.func_146228_f() / this.func_146244_h()) && i1 < this.mc.fontRenderer.FONT_HEIGHT * j1 + j1)
    {
        int k1 = i1 / this.mc.fontRenderer.FONT_HEIGHT + this.field_146250_j;

        if (k1 >= 0 && k1 < this.field_146253_i.size())
        {
            ChatLine chatline = (ChatLine)this.field_146253_i.get(k1);
            int l1 = 0;
            Iterator iterator = chatline.func_151461_a().iterator();

            while (iterator.hasNext())
            {
                IChatComponent ichatcomponent = (IChatComponent)iterator.next();

                if (ichatcomponent instanceof ChatComponentText)
                {
                    l1 += this.mc.fontRenderer.getStringWidth(this.func_146235_b(((ChatComponentText)ichatcomponent).getChatComponentText_TextValue()));

                    if (l1 > l)
                    {
                        return ichatcomponent;
                    }
                }
            }
        }

        return null;
    }
    return null;
}
return null;
  }
项目:RuneCraftery    文件:GuiNewChat.java   
public void func_73762_a(int p_73762_1_) {
   if(this.field_73772_a.field_71474_y.field_74343_n != 2) {
      int var2 = this.func_96127_i();
      boolean var3 = false;
      int var4 = 0;
      int var5 = this.field_96134_d.size();
      float var6 = this.field_73772_a.field_71474_y.field_74357_r * 0.9F + 0.1F;
      if(var5 > 0) {
         if(this.func_73760_d()) {
            var3 = true;
         }

         float var7 = this.func_96131_h();
         int var8 = MathHelper.func_76123_f((float)this.func_96126_f() / var7);
         GL11.glPushMatrix();
         GL11.glTranslatef(2.0F, 20.0F, 0.0F);
         GL11.glScalef(var7, var7, 1.0F);

         int var9;
         int var11;
         int var14;
         for(var9 = 0; var9 + this.field_73768_d < this.field_96134_d.size() && var9 < var2; ++var9) {
            ChatLine var10 = (ChatLine)this.field_96134_d.get(var9 + this.field_73768_d);
            if(var10 != null) {
               var11 = p_73762_1_ - var10.func_74540_b();
               if(var11 < 200 || var3) {
                  double var12 = (double)var11 / 200.0D;
                  var12 = 1.0D - var12;
                  var12 *= 10.0D;
                  if(var12 < 0.0D) {
                     var12 = 0.0D;
                  }

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

                  var12 *= var12;
                  var14 = (int)(255.0D * var12);
                  if(var3) {
                     var14 = 255;
                  }

                  var14 = (int)((float)var14 * var6);
                  ++var4;
                  if(var14 > 3) {
                     byte var15 = 0;
                     int var16 = -var9 * 9;
                     func_73734_a(var15, var16 - 9, var15 + var8 + 4, var16, var14 / 2 << 24);
                     GL11.glEnable(3042);
                     String var17 = var10.func_74538_a();
                     if(!this.field_73772_a.field_71474_y.field_74344_o) {
                        var17 = StringUtils.func_76338_a(var17);
                     }

                     this.field_73772_a.field_71466_p.func_78261_a(var17, var15, var16 - 8, 16777215 + (var14 << 24));
                  }
               }
            }
         }

         if(var3) {
            var9 = this.field_73772_a.field_71466_p.field_78288_b;
            GL11.glTranslatef(-3.0F, 0.0F, 0.0F);
            int var18 = var5 * var9 + var5;
            var11 = var4 * var9 + var4;
            int var20 = this.field_73768_d * var11 / var5;
            int var13 = var11 * var11 / var18;
            if(var18 != var11) {
               var14 = var20 > 0?170:96;
               int var19 = this.field_73769_e?13382451:3355562;
               func_73734_a(0, -var20, 2, -var20 - var13, var19 + (var14 << 24));
               func_73734_a(2, -var20, 1, -var20 - var13, 13421772 + (var14 << 24));
            }
         }

         GL11.glPopMatrix();
      }
   }
}
项目:TabbyChat-2    文件:ChatMessage.java   
public ChatMessage(ChatLine chatline) {
    this(chatline.getUpdatedCounter(), chatline.getChatComponent(), chatline.getChatLineID(), true);
}