Skip to content

Commit

Permalink
Correctly reflect vanilla scoreboard (fix #59)
Browse files Browse the repository at this point in the history
Team-specific slot can be null and should fall back on default sidebar.
  • Loading branch information
mccreery committed Jun 25, 2019
1 parent a0ea691 commit 8f6969c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/jobicade/betterhud/element/vanilla/Sidebar.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,24 @@ private List<Score> getScores(ScoreObjective objective) {
* Gets the objective in the player's sidebar slot.
* @param player The player.
* @return The objective in the player's sidebar slot.
* @see net.minecraft.client.gui.GuiIngame#renderGameOverlay(float)
*/
private ScoreObjective getObjective(EntityPlayer player) {
Scoreboard scoreboard = player.getWorldScoreboard();
ScoreObjective objective = null;
ScorePlayerTeam team = scoreboard.getPlayersTeam(MC.player.getName());

if(team != null) {
int slot = team.getColor().getColorIndex();

if(slot >= 0) {
return scoreboard.getObjectiveInDisplaySlot(3 + slot);
objective = scoreboard.getObjectiveInDisplaySlot(3 + slot);
}
}
return scoreboard.getObjectiveInDisplaySlot(1);

if(objective == null) {
objective = scoreboard.getObjectiveInDisplaySlot(1);
}
return objective;
}
}

0 comments on commit 8f6969c

Please sign in to comment.