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);
}
}
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;
}
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);
}
}
}
}
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);
}
}
}
}
}
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;
}
Aggregations