Talk:Scoreboard

@WolfieMario thanks for your great work on the initial versions of this article!  LB ( T 22:04, 24 January 2013 (UTC)
 * No problem :) --WolfieMario 03:30, 1 February 2013 (UTC)

Limits
Is there a limit to the amount of different "scores" that can be tracked? That is to say, is there a limit to the number of players that can be tracked on one scoreboard and the number of unique scoreboards that can be added? 115.70.128.50 12:51, 29 January 2013 (UTC)
 * It's theoretically unlimited (I'm sure there is no hard limit - that would make absolutely no sense), though of course it depends on their implementation for parsing/saving NBT and how the data is represented in memory. It could also just depend on how stuff in Java's standard library works. To be safe, though, try not to exceed ((2^31)-1) players or total scores, no matter how tempting it may be.  LB ( T 21:39, 29 January 2013 (UTC) -- Oh, and it also depends on how much memory and hard drive space you have.
 * You're correct; avoid anywhere near ((2^31)-1). In fact, the maximum number is probably closer to 2,147,483,639, surprisingly. The size of a list is stored as a 32-bit integer, so that's one hard limit of the NBT file format.


 * The 2,147,483,639 figure is eight less than the highest number a 32-bit int can store, because, depending on your JVM, arrays store header data in the array size, and thus that 32-bit int isn't fully available (although, I'm not quite sure how those eight values can store meaningful data; while it makes sense that the highest bit (used only for negatives) can store a bit of information, those additional eight values can't even form a single bit in this context. Perhaps those are literally eight reserved array indices, and the JVM adds eight to any referenced index for the non-header info? All I know is, strange as this information may be, it comes from the Java source code, which is about as credible as you can get). This limitation is especially relevant because NBT List tags are implemented using a Java ArrayList, which itself uses an array and explicitly declares 2,147,483,639 its maximum number of elements (thus, it wouldn't even vary by JVM, unless some JVM reserves more than eight values). Thus, ((2^31)-9) is the maximum number of elements an NBT List can store without risking crashes or corruption.


 * One caveat: this does not mean you can safely have ((2^31)-9) objectives. Let's hypothetically say you create ((2^31)-9) "deathCount" criteria objectives, for whatever reason. When one player dies, the game will allocate ((2^31)-9) elements in the PlayerScores list, filling it to capacity. Assuming this (or the existence of ((2^31)-9) objectives) hasn't yet caused your computer to implode, the moment a second player dies, you're guaranteed an OutOfMemoryException, even if your system had memory to spare, due to the JVM limit being surpassed. In general, you should limit your number of objectives based on the number of players you expect to have on a single map: if it's 30, then avoid going above (((2^31)-9)/30) objectives (that's 71,582,787, rounded down): even if not all players are likely to get scored in all objectives, it's best to not take the risk of crashing Minecraft.


 * Oh, and you know what's funny? All of these large numbers are actually entirely irrelevant. By my calculations, a single objective takes a minimum of 52 bytes (1 byte for the compound (although its header is omitted as it's in a list, it still has an End tag), 15 bytes CriteriaName header, 7 bytes minimum CriteriaName contents (I assume the criteria "dummy"), 14 bytes DisplayName header, 2 bytes minimum DisplayName contents (I assume an empty string), 7 bytes Name header, 6 bytes minimum Name contents (I assume 4 bytes worth of character data, else our theoretical max of ((2^31)-9) is impossible: this value must be unique for each objective. Note that 4 bytes is enough to encode a four-letter string)), not considering the effects of GZIP compression. At 52 bytes per uncompressed objective, our max of 2,147,483,639 would actually take around 104 gigabytes to store uncompressed. Sure, it may be less when compressed, but the whole thing has to be loaded into RAM, and Java's design actually means it may cost around 50% more in RAM. Assuming we can only afford to spend 3GB RAM on objective data (entirely ignoring the player data we also need), and assuming that Java indeed bloats the data to around 78 bytes per objective (considering we're talking about many String Objects, the references alone total 24 bytes, surprisingly close to the figure of 26 I tacked on... and that's assuming you're not in 64-bit Java!), you should seriously avoid having more than 41,297,762 objectives.


 * TL;DR:
 * The absolute limit is ((2^31)-9), or 2,147,483,639 objectives, but you'd be a madman to even try it.
 * If you don't want to crash even NASA's Minecraft when 30+ players play your map, avoid any more than 71,582,787.
 * If you have the slightest ounce of decency, and don't want your objectives to cost more than 3GB in RAM alone, don't go above 41,297,762.
 * If you're a normal person, you shouldn't be able to come up with more than a few hundred objectives anyhow, regardless of how large and complicated your map may be. Similarly, you'll never have enough players on a single such map for you to ever come close to these numbers, even in total.
 * TL;DR of the above: you literally don't even have to worry about it if you're just a normal mapmaker. Even Sethbling, myself, and anyone else who normally does complicated things has nothing to worry.
 * This is the first time I have put this sort of knowledge to use since my first year of Computer Science in college. --WolfieMario 03:30, 1 February 2013 (UTC)


 * I'm kinda speechless... :) 217.123.123.177 21:15, 5 February 2013 (UTC)

Scoreboard team table
Hello I made this table with the new team commands. I wrote it quite quickly so maybe there are mistakes in it. Where should I put the valid values for the options 'friendlyfire and color? Maybe adding a column to the table of Formatting codes with the official color names: black, dark_blue, dark_green etcetera

217.123.123.177 18:58, 31 January 2013 (UTC)

/testfor @a?
Say, I have set an objective X, and I use a command block with this line:

/testfor @a[score_X=3,score_X_min=3]

Will this command succeed only if all the players on this objective are exactly at 3, or is only one player with these criteria enough? 92.108.149.54 16:16, 16 May 2013 (UTC)

It will output a signal equal to the amount of players online with a score of X=3. If there is one, it will output one. if there is ten, it will output ten.

In order to do what you are wanting, make another command block that is "/testfor @a" and put a comparator on it. Make the comparator of the X score command block be in subtraction mode and then run a wire from the new command block's comparator to the side of the old one using exactly two redstone. This will make the X score comparator output a signal of one only when all players have an X score of three.

174.238.65.181 14:43, 8 July 2013 (UTC)

Using the Command
I have tried to activate the scoreboard, and it isn't working. Can anyone tell me how to use it by putting up an example?

The criteria I need are:

My Username is PrinceCooshie101, and I want the score to increase when I kill a mob

Please help me out!! PrinceCooshie101 02:48, 29 July 2013 (UTC)

P.S. could someone possibly put a tutorial up on the page on HOW to use it? (with examples, of course).

stat.entityKilledBy might work for passive mobs
In the article, it says passive mobs will never increase this. However, what about deaths such as being pushed off a cliff? I believe when death messages listing being pushed off were introduced, the first screenshot of it was one of the developers being pushed off by a pig. Would that increment the value? --MegaScience (talk) 05:55, 3 October 2013 (UTC)


 * Interesting idea. This image doesn't actually show the mob, as far as I can tell, and I thought they made passive mobs not push players around to avoid accidental deaths like that. -- Orthotopetalk 07:04, 3 October 2013 (UTC)


 * Hmm, that's true. Still, I'm curious if any other death hooks they added might influence passive mobs to count these. What other influences could a mob have on the player without attacking them? --MegaScience (talk) 08:43, 3 October 2013 (UTC)

What about having Multiple Criteria per Objective?
I wanted something to keep track of absolutely everything I fish...

ANYTHING I CAUGHT.

The scoreboard has criteria for fish, junk, and treasure.

Isn't there *ANY WAY AT ALL* I can just... you know... increment the same scoreboard line item each time any *one* of these happens...?


 * Can you just make a dummy objective, and have all 3 of those objectives track, and the dummy is the sum? AdmiralMemo (talk) 21:14, 3 February 2014 (UTC)

CONTRADICTION as offline/non-existent players can now have editable scores.
At Scoreboard players set, it says that offline players cannot be set. This is wrong, I just tested in 1.7.4 and it seems to work. Can I get someone to confirm this? --Kenblu24 (talk) 21:18, 13 February 2014 (UTC)

Confirmed. Works in 1.7.9 as well.

Help me with this one!
I need a scoreboard called "Challenge Number" for an adventure map I am making. I just want it to be up there so when the player steps on a pressure plate at the end of the challenge it adds one to the board for the player. I know how to add it (I think), I'll just do /scoreboard add Challenge Number @p 1. Correct me if I'm wrong and that will not work. But can anyone give me a tutorial?

Something for team winning
I am making an CTF map and at the end of the game I want there to be a message in the chat that says which team won. Is there a way for the command block to detect which score is higher? I have already set up the scoreboard (the name is TotalCaptures). Also is there a way to teleport only the players of a certain team? &#60;&#60; SchobbishBot3000 &#62;&#62; (talk) 02:01, 28 May 2014 (UTC)

Scoreboard advanced usage
Is there a way to use minecraft scoreboard variables for creating a creature with name, like /Summon ... {CustomName:score_Example,...}?

And if Example=15, then my creature should have name "15".

I would like to know that.

join offline user
I seem to be having some troubles with having a non-existing user join a team, it just says "The entity UUID provided is in an invalid format." Could someone please help me? Command: /scoreboard teams join testteam testuser1 --SuperKidKid (talk) 21:36, 4 July 2014 (UTC)
 * This is currently bugged, see: https://bugs.mojang.com/browse/MC-59052 Skylinerw (talk) 02:55, 5 July 2014 (UTC)

Could not parse dataTag, reason: Unable to locate name/value separator for string: name=Spawn_Giant
I am making a custom spawn egg system but when I run /scoreboard players set @e Spawn_Giant 1 {name=Spawn_Giant} It says Could not parse dataTag, reason: Unable to locate name/value separator for string: name=Spawn_Giant 24.130.131.83 05:02, 25 July 2014 (UTC)

Edit: Nevermind. I am using a different method now. -24.130.131.83 05:47, 25 July 2014 (UTC)

How to use the stat.*?
So how at all do I use the stat.*? For example, if I wanted to use stat.mineBlock.snow, how would I add that objective? I'm new to scoreboards, and I would like to learn. --70.114.129.183 15:03, 30 July 2014 (UTC) Thanks :D Alright, so, it's me again, and I've figured it out, but for some reason stat.mineBlock won't work, but all other stat.* will work. Is this a bug or something? How do I fix? --70.114.129.183 16:34, 30 July 2014 (UTC)

Tracking Non-Mob "Kills"
So, recently, in 1.9, a new mob called the "Shulker" has been added. It shoots a homing projectile witch the player can "kill" by punching it. Anyone know if it's possible yet to track those "kills"?

Can operation command use * as selector?
It seems that if you use commands like /scoreboard scoreboard players operation targetName targetObjective += selector objective will cause error because system cannot decide which player's score to operate to targer's.So while using * as selector,the operation must be swap?Hope for your reply.Kakagou12341 (talk) 15:22, 24 September 2015 (UTC)

RenderType
What are the other possible values of RenderType? --MCweb 00:52, 16 July 2016 (UTC)


 * There is currently only "integer" the default one, and "hearths" only used by the health criteria. Unfortunately this values is lost when the server send the scoreboard packet to the client, and the client receive the "correct" renderType based on the criteria. The sad part is that modding the game to properly send the custom renderType, seems to work fine, no weird things, and no crash. MrPingouin1 (talk) 05:11, 16 July 2016 (UTC)

How do you make the scoreboard know that a player should be tracked?
Jerryzhu2004 (talk) 05:29, 10 August 2016 (UTC)

If you change a score (even if you add 0) of an untracked player, this player will be made tracked Sun Cat (talk) 21:43, 31 August 2016 (UTC)

scoreboard teams leave [players...]
This syntax is invalid - it just uses as a fake-player name. (tested in 1.6.4, 1.10.2 and 16w33a)

This info could have been added because of MC-106681 (can't add a link)

Sun Cat (talk) 22:15, 31 August 2016 (UTC)

Changed the page myself =) Sun Cat (talk) 18:44, 3 September 2016 (UTC)

> and < operators


Run the following commands to instantiate scores:

/scoreboard objectives add OBJ dummy /scoreboard objectives setdisplay sidebar OBJ

/scoreboard players set p1 OBJ 20 /scoreboard players set p2 OBJ 30

p1 has a lower score than p2. Now run the following command:

/scoreboard players operation p1 OBJ < p2 OBJ

Nothing happens because p1 did not have a score higher than p2. The scores remain the same. Now use the opposite operator:

/scoreboard players operation p1 OBJ > p2 OBJ

p1 will have their score set to p2's score, because p1's score was lower than p2's score.

There is no such thing as a "true" score.

Skylinerw (talk) 09:33, 1 October 2016 (UTC)



After running those commands, I do see that that takes effect on their scores, now I do have a question stemming from this. I have made a bank system, deposit and withdrawal, for scores. I apparently confused myself, when I was making a bank in Vanilla (Which works without issue, I just did not understand my own coding....) using scoreboards I used these commands to "test" deposit amount against the currency. /scoreboard players operation @a depositam < @a currency What I did not realize is that once the depositam was greater than currency that it would just default to the maximum currency value. and the same went for withdrawal. It is still a necessary component of the bank and was placed in the right section of the commands, which is why it functions correctly, however I thought it was testing, rather it was failing and continuing through the commands to make the deposit. Just misunderstood what my values were actually doing. I apologize for the misunderstanding and the attempt to edit. AKA Kira (talk) 16:21, 1 October 2016 (UTC)