Posted July 2, 201411 yr Here's my example: So I want to strip the following information: - The title. In this case, "[1/3] Ends in 19:03" - The two teams, "Red" and "Blue" - The score of each team, 0 and 0 here. I was poking around in the scoreboard code and just could not figure it out. Any help is greatly appreciated. Here's what I've gotten so far: - The title. - Getting the objective names returns "§9Blue" and "§cRed" - Checking these values returns 0, even when Blue team has 1 point: ScoreObjective blueObjective = board.getObjective("§9Blue"); System.out.println(board.func_96529_a("§9Blue", blueObjective).getScorePoints());
July 2, 201411 yr Author Managed to get the title of the scoreboard like this: ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(1); String scoreTitle = scoreobjective.getDisplayName(); EDIT: Actually this seems to be crashing sometimes :\. Changed it to this: if (this.mc.theWorld.getScoreboard().func_96539_a(0) != null) { boardTitle = this.mc.theWorld.getScoreboard().func_96539_a(0).getDisplayName(); } else { boardTitle = this.mc.theWorld.getScoreboard().func_96539_a(1).getDisplayName(); }
July 3, 201411 yr Author I did it! . I even wrote some functions for it: Getting the title, in my case "[1/3] Ends in 19:03": /** * Returns the "title" of the scoreboard's display. */ public static String getBoardTitle(Scoreboard board) { // Grab the main objective of the scoreboard. ScoreObjective titleObjective = board.func_96539_a(1); // Null check. For some reason, sometimes _a(0) works and other times _a(1) works. if (board.func_96539_a(0) != null) { return board.func_96539_a(0).getDisplayName(); } else { return board.func_96539_a(1).getDisplayName(); } } In my example, I would just need to do: System.out.println(Stats.getBoardTitle(this.mc.theWorld.getScoreboard())); Getting the score of the teams: /** * Returns the score of the "team" (really a fake player) on the scoreboard. */ public static int getTeamScore(String team, Scoreboard board) { // Grab the main objective of the scoreboard. ScoreObjective objective = board.func_96539_a(1); // Collection of all scoreboard entries. Collection collection = board.func_96534_i(objective); // Iterate through the collection of entries. Iterator iterator1 = collection.iterator(); while (iterator1.hasNext()) { Score score = (Score)iterator1.next(); // Check if the name of the "team" (player) is what we're looking for. // In actuality, it would be better to use an equals check e.g.: // if (score1.getPlayerName().equals(team)) { if (score.getPlayerName().contains(team)) { // Get the score of the "team" (player) and return it. return score.getScorePoints(); } } return -1; } So, for my example, I could just do: System.out.println(Stats.getTeamScore("Blue", board)); System.out.println(Stats.getTeamScore("Red", board));
July 3, 201411 yr Congratulations! I dub you Forge Forums Modder of the Week. You solved it all on your own We all stuff up sometimes... But I seem to be at the bottom of that pot.
July 3, 201411 yr Author Actually, I'm still getting some crashes from grabbing the title . I'm working on it though . I'd also like to remove the scoreboard. I wonder if that's possible.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.