Search in sources :

Example 21 with ScoreObjective

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

the class MixinRenderPlayer method renderOffsetLivingLabel.

/**
 * @author Sk1er
 * @reason Cancel nametag render event when score is renderer
 */
@Overwrite
protected void renderOffsetLivingLabel(AbstractClientPlayer entityIn, double x, double y, double z, String str, float p_177069_9_, double p_177069_10_) {
    if (p_177069_10_ < 100.0D) {
        Scoreboard scoreboard = entityIn.getWorldScoreboard();
        ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(2);
        if (scoreobjective != null) {
            Score score = scoreboard.getValueFromObjective(entityIn.getName(), scoreobjective);
            RenderNameTagEvent.CANCEL = true;
            if (entityIn != Minecraft.getMinecraft().thePlayer) {
                renderLivingLabel(entityIn, score.getScorePoints() + " " + scoreobjective.getDisplayName(), x, y, z, 64);
                y += (float) getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * p_177069_9_;
            }
            RenderNameTagEvent.CANCEL = false;
        }
    }
    super.renderOffsetLivingLabel(entityIn, x, y, z, str, p_177069_9_, p_177069_10_);
}
Also used : Score(net.minecraft.scoreboard.Score) ScoreObjective(net.minecraft.scoreboard.ScoreObjective) Scoreboard(net.minecraft.scoreboard.Scoreboard) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 22 with ScoreObjective

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

the class TabList method getNamesByObjectives.

/**
 * Gets names set in scoreboard objectives (useful for newer games)
 *
 * @return The formatted names
 */
public static List<String> getNamesByObjectives() {
    List<String> tabNames = new ArrayList<>();
    try {
        Scoreboard scoreboard = World.getWorld().getScoreboard();
        ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(0);
        Collection<Score> scores = scoreboard.getSortedScores(sidebarObjective);
        for (Score score : scores) {
            ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
            String name = ScorePlayerTeam.formatPlayerName(team, score.getPlayerName());
            tabNames.add(name);
        }
    } catch (Exception e) {
        return new ArrayList<>();
    }
    return tabNames;
}
Also used : Score(net.minecraft.scoreboard.Score) ScoreObjective(net.minecraft.scoreboard.ScoreObjective) Scoreboard(net.minecraft.scoreboard.Scoreboard) ArrayList(java.util.ArrayList) ScorePlayerTeam(net.minecraft.scoreboard.ScorePlayerTeam)

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