Search in sources :

Example 1 with RenderScoreboardEvent

use of cc.hyperium.event.render.RenderScoreboardEvent in project Hyperium by HyperiumClient.

the class ScoreboardRenderer method render.

public void render(ScoreObjective objective, ScaledResolution resolution) {
    RenderScoreboardEvent renderEvent = new RenderScoreboardEvent(xLocation, yLocation, objective, resolution);
    EventBus.INSTANCE.post(renderEvent);
    if (!renderEvent.isCancelled()) {
        Scoreboard scoreboard = objective.getScoreboard();
        Collection<Score> collection = scoreboard.getSortedScores(objective);
        List<Score> list = collection.stream().filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")).collect(Collectors.toList());
        collection = list.size() > 15 ? Lists.newArrayList(Iterables.skip(list, collection.size() - 15)) : list;
        int i = getFontRenderer().getStringWidth(objective.getDisplayName());
        for (Score score : collection) {
            ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(score.getPlayerName());
            String s = ScorePlayerTeam.formatPlayerName(scoreplayerteam, score.getPlayerName()) + ": " + EnumChatFormatting.RED + score.getScorePoints();
            i = Math.max(i, getFontRenderer().getStringWidth(s));
        }
        int i1 = collection.size() * getFontRenderer().FONT_HEIGHT;
        int j1 = (int) (resolution.getScaledHeight_double() * yLocation) + i1 / 3;
        int k1 = 3;
        int l1 = (int) (resolution.getScaledWidth_double() * xLocation) - i - k1;
        int j = 0;
        for (Score score1 : collection) {
            ++j;
            ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score1.getPlayerName());
            String s1 = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score1.getPlayerName());
            String s2 = EnumChatFormatting.RED.toString() + score1.getScorePoints();
            int k = j1 - j * getFontRenderer().FONT_HEIGHT;
            int l = (int) (resolution.getScaledWidth_double() * xLocation) - k1 + 2;
            RenderUtils.drawRect(l1 - 2, k, l, k + getFontRenderer().FONT_HEIGHT, 1342177280);
            getFontRenderer().drawString(s1, l1, k, 553648127);
            getFontRenderer().drawString(s2, l - getFontRenderer().getStringWidth(s2), k, 553648127);
            if (j == collection.size()) {
                String s3 = objective.getDisplayName();
                RenderUtils.drawRect(l1 - 2, k - getFontRenderer().FONT_HEIGHT - 1, l, k - 1, 1610612736);
                RenderUtils.drawRect(l1 - 2, k - 1, l, k, 1342177280);
                getFontRenderer().drawString(s3, l1 + i / 2 - getFontRenderer().getStringWidth(s3) / 2, k - getFontRenderer().FONT_HEIGHT, 553648127);
            }
        }
    }
}
Also used : Iterables(com.google.common.collect.Iterables) ScaledResolution(net.minecraft.client.gui.ScaledResolution) EventBus(cc.hyperium.event.EventBus) ScoreObjective(net.minecraft.scoreboard.ScoreObjective) Collection(java.util.Collection) RenderUtils(cc.hyperium.utils.RenderUtils) RenderScoreboardEvent(cc.hyperium.event.render.RenderScoreboardEvent) Collectors(java.util.stream.Collectors) List(java.util.List) Lists(com.google.common.collect.Lists) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft) Score(net.minecraft.scoreboard.Score) ConfigOpt(cc.hyperium.config.ConfigOpt) ScorePlayerTeam(net.minecraft.scoreboard.ScorePlayerTeam) Scoreboard(net.minecraft.scoreboard.Scoreboard) EnumChatFormatting(net.minecraft.util.EnumChatFormatting) Score(net.minecraft.scoreboard.Score) Scoreboard(net.minecraft.scoreboard.Scoreboard) RenderScoreboardEvent(cc.hyperium.event.render.RenderScoreboardEvent) ScorePlayerTeam(net.minecraft.scoreboard.ScorePlayerTeam)

Aggregations

ConfigOpt (cc.hyperium.config.ConfigOpt)1 EventBus (cc.hyperium.event.EventBus)1 RenderScoreboardEvent (cc.hyperium.event.render.RenderScoreboardEvent)1 RenderUtils (cc.hyperium.utils.RenderUtils)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 Score (net.minecraft.scoreboard.Score)1 ScoreObjective (net.minecraft.scoreboard.ScoreObjective)1 ScorePlayerTeam (net.minecraft.scoreboard.ScorePlayerTeam)1 Scoreboard (net.minecraft.scoreboard.Scoreboard)1 EnumChatFormatting (net.minecraft.util.EnumChatFormatting)1