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

I am having problems setting the scoreboard objective display slot. I have a simple score called "score" (for testing purposes), and I want to set the slot to be in the sidebar. I created the score through my code using this method:

 

/**
	 * Set the specified score of the entity. Will create score is score does not exist.
	 * 
	 * @param world
	 * @param entity
	 * @param objective
	 * @param value
	 */
	public static void setScore(World world, Entity entity, String objective, int value) {
		if (entity instanceof EntityPlayer) {
			 world.getScoreboard().getOrCreateScore(entity.getName(), world.getScoreboard().getObjective(objective)).setScorePoints(value);
			 //world.getScoreboard().broadcastScoreUpdate(entity.getName(), world.getScoreboard().getObjective(objective));
		} else {
			 world.getScoreboard().getOrCreateScore(entity.getCachedUniqueIdString(), world.getScoreboard().getObjective(objective)).setScorePoints(value);
			 //world.getScoreboard().broadcastScoreUpdate(entity.getCachedUniqueIdString(), world.getScoreboard().getObjective(objective));
		}
	}

 

When I try to run the command for this, I get the error that the score doesn't exist. When I try to do it from this method:

/**
	 * Set the display slot of the score.
	 * 
	 * Can be list, sidebar, or belowName.
	 * 
	 * @param world
	 * @param slot
	 * @param objective
	 */
	public static void setScoreDisplaySlot(World world, String slot, String objective) {
		Scoreboard scoreboard = world.getScoreboard();
		
		int i = Scoreboard.getObjectiveDisplaySlotNumber(slot);
		
		ScoreObjective objectiveToUse = scoreboard.getObjective(objective);
		
		scoreboard.setObjectiveInDisplaySlot(i, objectiveToUse);
	}

 

(I got that method from the CommandScore class)

 

nothing happens.

 

If I try to create the score in the function using this code:

 

if (!scoreboard.getObjectiveNames().contains(objective)) {
			scoreboard.addScoreObjective(objective, IScoreCriteria.DUMMY);
		}

 

the code in my statement runs, but I get an error that the score already existed.

 

If the score already existed, then the command would have been able to sense it, and my code to create the objective should not have run.

 

Getting and setting the score seems to work perfectly fine in the code.

Edited by ptolemy2002

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.