Search in sources :

Example 16 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project SpongeCommon by SpongePowered.

the class SpongeObjective method updateDisplayName.

private void updateDisplayName() {
    for (ScoreObjective objective : this.objectives.values()) {
        objective.displayName = SpongeTexts.toLegacy(this.displayName);
        objective.scoreboard.onObjectiveDisplayNameChanged(objective);
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective)

Example 17 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project SpongeCommon by SpongePowered.

the class SpongeObjective method removeScore.

@Override
public boolean removeScore(Score spongeScore) {
    String name = ((SpongeScore) spongeScore).legacyName;
    if (!this.scores.containsKey(spongeScore.getName())) {
        return false;
    }
    for (ScoreObjective objective : this.objectives.values()) {
        net.minecraft.scoreboard.Scoreboard scoreboard = objective.scoreboard;
        Map<?, ?> map = scoreboard.entitiesScoreObjectives.get(name);
        if (map != null) {
            net.minecraft.scoreboard.Score score = (net.minecraft.scoreboard.Score) map.remove(objective);
            if (map.size() < 1) {
                Map<?, ?> map1 = scoreboard.entitiesScoreObjectives.remove(name);
                if (map1 != null) {
                    scoreboard.broadcastScoreUpdate(name);
                }
            } else if (score != null) {
                scoreboard.broadcastScoreUpdate(name, objective);
            }
        }
        ((SpongeScore) spongeScore).removeScoreFor(objective);
    }
    this.scores.remove(spongeScore.getName());
    return true;
}
Also used : Score(org.spongepowered.api.scoreboard.Score) ScoreObjective(net.minecraft.scoreboard.ScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective)

Example 18 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective 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)

Example 19 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project Hyperium by HyperiumClient.

the class LevelheadGui method drawPingHook.

public static void drawPingHook(int i, int x, int y, NetworkPlayerInfo playerInfo) {
    if (!Levelhead.getInstance().getDisplayManager().getMasterConfig().isEnabled()) {
        return;
    }
    Levelhead instance = Levelhead.getInstance();
    LevelheadDisplay tab = instance.getDisplayManager().getTab();
    if (tab != null) {
        if (!tab.getConfig().isEnabled())
            return;
        if (instance.getLevelheadPurchaseStates().isTab()) {
            String s = tab.getTrueValueCache().get(playerInfo.getGameProfile().getId());
            if (s != null) {
                FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
                int x1 = i + x - 12 - fontRenderer.getStringWidth(s);
                Scoreboard board = Minecraft.getMinecraft().theWorld.getScoreboard();
                ScoreObjective objective = board.getObjectiveInDisplaySlot(0);
                if (objective != null) {
                    int score = board.getValueFromObjective(playerInfo.getGameProfile().getName(), objective).getScorePoints();
                    int extraWidth = fontRenderer.getStringWidth(" " + score);
                    x1 -= extraWidth;
                }
                DisplayConfig config = tab.getConfig();
                if (config.isFooterChroma()) {
                    fontRenderer.drawString(s, x1, y, instance.getRGBColor());
                } else if (config.isFooterRgb()) {
                    fontRenderer.drawString(s, x1, y, new Color(config.getFooterRed(), config.getFooterGreen(), config.getFooterBlue()).getRGB());
                } else {
                    fontRenderer.drawString(config.getFooterColor() + s, x1, y, -1);
                }
            }
        }
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) Scoreboard(net.minecraft.scoreboard.Scoreboard) Levelhead(cc.hyperium.mods.levelhead.Levelhead) ChatColor(cc.hyperium.utils.ChatColor)

Example 20 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project Hyperium by HyperiumClient.

the class GuiScreenSidebar method drawScreen.

public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    super.drawScreen(mouseX, mouseY, partialTicks);
    if (mc.thePlayer != null) {
        ScoreObjective scoreObjective = mc.thePlayer.getWorldScoreboard().getObjectiveInDisplaySlot(1);
        if (scoreObjective != null)
            sidebar.drawSidebar(scoreObjective, new ScaledResolution(mc));
    }
    if (dragging) {
        sidebar.offsetX += mouseX - lastX;
        sidebar.offsetY += mouseY - lastY;
    }
    lastX = mouseX;
    lastY = mouseY;
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) ScoreObjective(net.minecraft.scoreboard.ScoreObjective)

Aggregations

ScoreObjective (net.minecraft.scoreboard.ScoreObjective)22 IMixinScoreObjective (org.spongepowered.common.interfaces.IMixinScoreObjective)10 Score (net.minecraft.scoreboard.Score)7 Scoreboard (net.minecraft.scoreboard.Scoreboard)7 SpongeObjective (org.spongepowered.common.scoreboard.SpongeObjective)4 ScaledResolution (net.minecraft.client.gui.ScaledResolution)3 ScorePlayerTeam (net.minecraft.scoreboard.ScorePlayerTeam)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 IScoreCriteria (net.minecraft.scoreboard.IScoreCriteria)2 Score (org.spongepowered.api.scoreboard.Score)2 Overwrite (org.spongepowered.asm.mixin.Overwrite)2 IMixinScore (org.spongepowered.common.interfaces.IMixinScore)2 SpongeScore (org.spongepowered.common.scoreboard.SpongeScore)2 ConfigOpt (cc.hyperium.config.ConfigOpt)1 EventBus (cc.hyperium.event.EventBus)1 InvokeEvent (cc.hyperium.event.InvokeEvent)1 RenderScoreboardEvent (cc.hyperium.event.render.RenderScoreboardEvent)1