Search in sources :

Example 11 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project ct.js by ChatTriggers.

the class Scoreboard method updateNames.

private static void updateNames() {
    if (!scoreboardNames.isEmpty()) {
        scoreboardNames.clear();
    }
    scoreboardTitle = "";
    try {
        net.minecraft.scoreboard.Scoreboard scoreboard = World.getWorld().getScoreboard();
        ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
        scoreboardTitle = sidebarObjective.getDisplayName();
        Collection<net.minecraft.scoreboard.Score> scores = scoreboard.getSortedScores(sidebarObjective);
        scoreboardNames = scores.stream().map(Score::new).collect(Collectors.toList());
    } catch (Exception ignored) {
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective)

Example 12 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project ct.js by ChatTriggers.

the class Scoreboard method setLine.

/**
 * Sets a line in the scoreboard to the specified name and score.
 *
 * @param score the score value for this item
 * @param line the string to display on said line
 * @param override whether or not to remove old lines with the same score
 */
public static void setLine(int score, String line, boolean override) {
    try {
        net.minecraft.scoreboard.Scoreboard scoreboard = World.getWorld().getScoreboard();
        ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
        Collection<net.minecraft.scoreboard.Score> scores = scoreboard.getSortedScores(sidebarObjective);
        if (override) {
            for (net.minecraft.scoreboard.Score theScore : scores) {
                if (theScore.getScorePoints() == score) {
                    scoreboard.removeObjectiveFromEntity(theScore.getPlayerName(), sidebarObjective);
                }
            }
        }
        net.minecraft.scoreboard.Score theScore = scoreboard.getValueFromObjective(line, sidebarObjective);
        theScore.setScorePoints(score);
    } catch (Exception ignored) {
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective)

Example 13 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project MinecraftForge by MinecraftForge.

the class GuiIngameForge method renderPlayerList.

protected void renderPlayerList(int width, int height) {
    ScoreObjective scoreobjective = this.mc.world.getScoreboard().getObjectiveInDisplaySlot(0);
    NetHandlerPlayClient handler = mc.player.connection;
    if (mc.gameSettings.keyBindPlayerList.isKeyDown() && (!mc.isIntegratedServerRunning() || handler.getPlayerInfoMap().size() > 1 || scoreobjective != null)) {
        this.overlayPlayerList.updatePlayerList(true);
        if (pre(PLAYER_LIST))
            return;
        this.overlayPlayerList.renderPlayerlist(width, this.mc.world.getScoreboard(), scoreobjective);
        post(PLAYER_LIST);
    } else {
        this.overlayPlayerList.updatePlayerList(false);
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) NetHandlerPlayClient(net.minecraft.client.network.NetHandlerPlayClient)

Example 14 with ScoreObjective

use of net.minecraft.scoreboard.ScoreObjective in project MinecraftForge by MinecraftForge.

the class GuiIngameForge method renderGameOverlay.

@Override
public void renderGameOverlay(float partialTicks) {
    res = new ScaledResolution(mc);
    eventParent = new RenderGameOverlayEvent(partialTicks, res);
    int width = res.getScaledWidth();
    int height = res.getScaledHeight();
    renderHealthMount = mc.player.getRidingEntity() instanceof EntityLivingBase;
    renderFood = mc.player.getRidingEntity() == null;
    renderJumpBar = mc.player.isRidingHorse();
    right_height = 39;
    left_height = 39;
    if (pre(ALL))
        return;
    fontrenderer = mc.fontRendererObj;
    mc.entityRenderer.setupOverlayRendering();
    GlStateManager.enableBlend();
    if (Minecraft.isFancyGraphicsEnabled()) {
        renderVignette(mc.player.getBrightness(partialTicks), res);
    } else {
        GlStateManager.enableDepth();
        GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    }
    if (renderHelmet)
        renderHelmet(res, partialTicks);
    if (renderPortal && !mc.player.isPotionActive(MobEffects.NAUSEA)) {
        renderPortal(res, partialTicks);
    }
    if (renderHotbar)
        renderHotbar(res, partialTicks);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    zLevel = -90.0F;
    rand.setSeed((long) (updateCounter * 312871));
    if (renderCrosshairs)
        renderCrosshairs(partialTicks);
    if (renderBossHealth)
        renderBossHealth();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    if (this.mc.playerController.shouldDrawHUD() && this.mc.getRenderViewEntity() instanceof EntityPlayer) {
        if (renderHealth)
            renderHealth(width, height);
        if (renderArmor)
            renderArmor(width, height);
        if (renderFood)
            renderFood(width, height);
        if (renderHealthMount)
            renderHealthMount(width, height);
        if (renderAir)
            renderAir(width, height);
    }
    renderSleepFade(width, height);
    if (renderJumpBar) {
        renderJumpBar(width, height);
    } else if (renderExperiance) {
        renderExperience(width, height);
    }
    renderToolHighlight(res);
    renderHUDText(width, height);
    renderFPSGraph();
    renderPotionIcons(res);
    renderRecordOverlay(width, height, partialTicks);
    renderSubtitles(res);
    renderTitle(width, height, partialTicks);
    Scoreboard scoreboard = this.mc.world.getScoreboard();
    ScoreObjective objective = null;
    ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(mc.player.getName());
    if (scoreplayerteam != null) {
        int slot = scoreplayerteam.getChatFormat().getColorIndex();
        if (slot >= 0)
            objective = scoreboard.getObjectiveInDisplaySlot(3 + slot);
    }
    ScoreObjective scoreobjective1 = objective != null ? objective : scoreboard.getObjectiveInDisplaySlot(1);
    if (renderObjective && scoreobjective1 != null) {
        this.renderScoreboard(scoreobjective1, res);
    }
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
    GlStateManager.disableAlpha();
    renderChat(width, height);
    renderPlayerList(width, height);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableLighting();
    GlStateManager.enableAlpha();
    post(ALL);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) ScoreObjective(net.minecraft.scoreboard.ScoreObjective) Scoreboard(net.minecraft.scoreboard.Scoreboard) RenderGameOverlayEvent(net.minecraftforge.client.event.RenderGameOverlayEvent) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ScorePlayerTeam(net.minecraft.scoreboard.ScorePlayerTeam)

Example 15 with ScoreObjective

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

the class SpongeObjective method updateDisplayMode.

private void updateDisplayMode() {
    for (ScoreObjective objective : this.objectives.values()) {
        objective.renderType = (IScoreCriteria.EnumRenderType) (Object) this.displayMode;
        objective.scoreboard.onObjectiveDisplayNameChanged(objective);
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) IScoreCriteria(net.minecraft.scoreboard.IScoreCriteria)

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