Updated: Sep 8, 2021
Hi everyone! So in this Class Notes, we will be learning the Scoreboard command. The scoreboard command is basically a number-tracking command, so it sounds simple, but it really isn't. In fact, I think this is the hardest command to wrap your mind around in Minecraft!
We only learned a portion of this command in class, so I will have two sections: everything we learned in class, and another section detailing every little piece of syntax as well as cool ways we can use this, especially with the execute command.
First off, we use things called 'objectives' in scoreboards. When you create an objective, it creates a list of every player's score. For example, if I made a new objective called 'coins', everyone on the server would have a value of 0 on the score, since no points have been given. We can have ways to increase this score as well, for example, if a player right-clicks with a certain item, their score goes up by a set amount.
To create an objective, we can start by typing out the command:
/scoreboard objectives add (objectivename)
Then, we need to specify the criteria. Now the criteria are whatever the player has to do to increase their value.
We only use a few of these:
dummy minecraft.used:(item) minecraft.mined:(item) minecraft.dropped:(item) minecraft.picked_up:(item) minecraft.crafted:(item) minecraft.broken:(item)
We can choose any of these for our criteria. After we put in the criteria we want, we can run the command and your objective has been created.
Now, let's get into what these criteria do.
Let's start with the first. 'dummy' means that the value can't go up unless we use a command to do it. This is very useful, and you will see why further down.
For minecraft.used:(item), we can put whatever item we want in the item slot. That means that viable criteria would be:
When we say 'used' we are saying that the value goes up when we right-click with the object and then something happens. For example, this would go up if I placed oak planks somewhere as I am right-clicking and something is happening. Same if I right-clicked with a carrot. Since I am eating the carrot by right-clicking, the value will go up. The value will not go up, though, if I am at full hunger for example, because I can't eat a carrot if I am at full saturation.
When we create datapacks, we often use carrot-on-a-sticks as when we right-click on them, it sends a packet to the server, which we can obviously trace using these criteria. This makes it super easy to trace right-clicks, so we can have custom abilities with a sword or have it be a cool wand to summon a fireball, or maybe even a rocket launcher! It may seem daunting at first, but it's all possible with a ton of scoreboard and execute commands. If you want to find out how to create a datapack, watch this video:
That's pretty much it for the minecraft.used:(item) criteria, on to the next.
When we look at 'minecraft.mined:(item)', it's pretty easy to understand what it does. A bunch of these are self-explanatory. When we utilize these criteria, it goes up whenever we mine a certain block. Obviously, the value would be impossible to increase if we chose an item like a stick, as we can't mine sticks since they aren't blocks. But if we did something like
'minecraft.mined:diamond_ore', will go up every time that a player mines the block.
NOTE: the player does not need to pick up the item produced from the block. For example, if I mined obsidian with my bare hands (which would take a very long time) I wouldn't get the obsidian, but the value would still go up.
'minecraft.broken:(item)' is also self-explanatory. It goes up every time a player breaks any tool, like a sword or something like that. Obviously, if we chose something like 'minecraft.broken:diamond_ore' it would not be possible for the score to go up as diamond ore blocks don't have durability. Same for 'minecraft.dropped:(item)' and 'minecraft.picked_up:(item)'. These are the most self-explanatory of them all.
For the last, we have 'minecraft.crafted:(item)'. This goes up every time that we craft an item.
Now that we know all the criteria, let's take a step back real quick.
When we go back to /scoreboard objectives, we have 5 options:
Add (we just went over this)
Let's start from the top down. 'List' is pretty self-explanatory. If we run the command:
/scoreboard objectives list
This will list all the objectives in the game.
Next is 'modify'. This allows us to modify the display name of the objective. For example, if we run the command:
/scoreboard objectives modify (objective name) (JSON)
As you might have guessed, in (JSON) we put the display name in JSON format. If you don't know how to write in JSON, read my article on it here:
Next, we have 'remove'. This is pretty self-explanatory. We can remove any scoreboard using this command. As you may know, we are currently working on the WequilCraft project (or you might be reading this a bajillion years in the future). We are trying to work on a solution to make sure that players can't remove anyone's scoreboard within the server, while still having OP permissions to use command blocks.
Last, but not least, we have 'setdisplay'. This allows you to display your scoreboard anywhere, but keep in mind, we can only have one scoreboard displaying in each criterion.
If we start typing out the command:
/scoreboard objectives setdisplay (criteria) (objective)
We can choose from three criteria:
If we pick 'list', it will show the value of each player relative to the objective specified in TAB.
TIP: TAB is the menu where you can view all the players online. We can view this if we hold down TAB, but this feature is exclusive to servers and realms.
If we pick 'belowname', it will show the value of each player relative to the objective specified under their in-game username on top of their Minecraft character.
If we pick 'sidebar', it will display the player's values on the side of the screen, next to their name.
Now, let's take another big step back. We covered everything in 'objectives', now we can move on to 'players'.
If we start typing out the command:
we are greeted with a collection of options:
We will start from the top. The 'add' argument allows us to add to a player's value relative to a certain objective. For example, if I ran the command:
/scoreboard players add Benny exampleObj 5
This will increase my score by 5, relative to the 'exampleObj' objective. On to the next argument!
Using the 'get' argument, we can view how many points a player has relative to a certain objective, without the need of using the 'setdisplay' argument.
For example, if I ran the command:
/scoreboard players get Benny exampleObj
This command would print out in chat the value I have in the objective. On to the next argument!
Using the 'list' argument, we can view the value of a certain player relative to every objective they have a value in. For example, given that I have a value of 10 in the 'exampleObj1' objective, and a value of 5 in the 'exampleObj2' objective, if I ran the command:
/scoreboard players list Kji
This would print in chat that I have a value of 5 in 'exampleObj1' and a value of 10 in 'exampleObj2'. On to the next argument!
Using the 'operation' argument, we can apply an arithmetic operation to the target's score.
This one is pretty confusing.
We are comparing the target's score to a source's score (another player). For example, if I ran the command:
/scoreboard players operation Benny exampleObj1 += Beckett exampleObj1
This is going to add my score in exampleObj1 to Beckett's score in exampleObj1. That is what the '+=' argument means, and it is also how we are altering my score. There are quite a few of these, so I will list all of them down below.
First, we need to break down the command. I am the 'target' in this command, meaning I am the person whose score is getting altered. Beckett is the source, meaning we are just comparing my score and his and altering MY score ONLY base on the results. Here are all the ways we can do this:
"+=" Addition: Adds the source's score to the target's score
"-=" Subtraction: Subtracts the source's score from the target's score
"*=" Multiplication: Sets the target's score to the product of the target's and source's scores
"/=" Division: Divides the target's score by the source's scores, and the result will be floored (rounded down to an integer)
"%=" Modulus: Divides the target's score by the source's score, and use the remainder to set the target's score
"=" Assign: Sets the target's score to the source's score
"<" Min: Sets the target's score to the source's score only if the source's score is less than the target's score.
">" Max: Sets the target's score to the source's score only if the source's score is bigger than the target's score.
"><" Swaps the target's score and the source's score
That's it for the 'operation' argument, on to the next!
The 'remove' argument allows us to remove a certain value from a player's score. If I run the command:
/scoreboard players remove Benny exampleObj 5
This would remove a value of 5 from my score relative to the 'exampleObj' objective. Pretty self-explanatory. On to the next argument!
If we use the 'reset' argument, we can reset a player's score relative to any objective. For example, if I ran the command:
/scoreboard players reset Benny exampleObj
This would reset my value to 0 relative to the exampleObj objective. On to the last argument, finally!
Using the 'set' argument, we can set any player's value relative to a certain objective to anything we want. For example, if I ran the command:
/scoreboard players set Benny exampleObj 1000
This would set my score in exampleObj to a whopping 1,000!
And on that note, you have finished (and hopefully learned) everything about the scoreboard command, the hardest command in Minecraft! Congratulations :)