Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Here's my example:

R8rr16xx.png

 

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());

  • 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();
        }

  • Author

I did it! :D. 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));

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.

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.