Data Commands
Commands for managing NBT data, scoreboards, teams, tags, advancements, and recipes.
/advancementGrants or revokes advancements from players. Can target specific advancements, advancement trees, or all advancements.
/dataGets, merges, modifies, or removes NBT data from entities, block entities, or storage. A powerful command for advanced data manipulation.
/recipeGives or takes recipe knowledge from players. Affects which recipes appear in the recipe book.
/scoreboardManages scoreboard objectives and player scores. The scoreboard system tracks numeric values for entities and can display them in various locations.
/tagAdds, removes, or lists tags on entities. Tags are simple string labels used for entity selection and organization.
/teamManages teams for the scoreboard. Teams control PvP, name colors, collision rules, and name visibility.
What /data can reach
/data reads and changes NBT in three kinds of place: a block entity such as a chest or a sign, a single entity, or a storage. A storage is a named compound like mypack:state that belongs to no block and no entity. It is saved with the world, which makes it a good place to keep values between function runs.
get reads, merge combines a compound with what is already there, modify changes one path with set, append, prepend, insert or merge, and remove deletes a path. Players are the exception. /data reads a player without complaint, but merge, modify and remove all fail on one, and a player you name has to be online.
With a path, /data get also returns a number, and that number is what execute store result saves: a numeric value rounded down, the length of a string, the number of entries in a list or the number of keys in a compound. A scale is multiplied in before the rounding, so /data get entity @s Pos[1] 100 gives your Y coordinate in hundredths of a block.
Scoreboard objectives
An objective is a named score plus a criterion, and the criterion decides what changes it. dummy only moves when a command moves it, which makes it the one to pick for counters and variables. deathCount, playerKillCount and totalKillCount go up by themselves. health, food, air, armor, xp and level follow the player, and commands can't change them.
trigger is meant for scores that players change themselves. A player can only use /trigger on an objective after /scoreboard players enable, and using it takes that permission away again, so a clickable menu has to switch it back on after every use.
Where scores show up
list- The player list you open with Tab. The score shows as a yellow number, or as hearts with
rendertype hearts. sidebar- The right side of the screen, with the 15 highest scores. Names that start with # never appear there, which is why counters often live on a fake player like
#timer. below_name- Under the name above each player's head. Before Java 1.20.2 this slot was called belowName.
sidebar.team.<color>- A sidebar that only members of a team with that color see. There is one for each of the 16 team colors.
/scoreboard players operation does arithmetic between two scores. It knows =, +=, -=, *=, /= and %=, plus < to keep the lower score, > to keep the higher one and >< to swap the two. Division rounds down, and %= always leaves a positive remainder.
Teams
/team add creates a team and /team join puts players or other entities in it. Leave the names off and it adds whoever ran the command. The rest goes through /team modify:
color- Colors the names of the members and decides which team sidebar they see. Starts as reset, the normal color.
friendlyFire- Whether members can hurt each other. On by default.
seeFriendlyInvisibles- Invisible teammates show up see-through instead of disappearing. On by default.
nametagVisibilityanddeathMessageVisibility- always, never, hideForOtherTeams or hideForOwnTeam. Both start at always.
collisionRule- always, never, pushOtherTeams or pushOwnTeam. The last two work the other way round from what their names suggest, which is filed as bug MC-87984.
prefixandsuffix- Text shown before and after the name of each member.
Tags
/tag sticks a word on an entity so that a selector can find it again. @e[tag=boss] picks every entity tagged boss, @e[tag=!boss] every entity without that tag and @e[tag=] the ones with no tags at all. In Java Edition one entity can carry up to 1024 of them. These have nothing to do with the tags in a data pack, such as #minecraft:logs, which group blocks, items or entity types.
Advancements and recipes
/advancement grants or revokes in five ways. everything covers every loaded advancement, only one advancement or a single criterion of it, from an advancement plus all that come after it in its tree, until an advancement plus all before it back to the root, and through does both.
/recipe unlocks or locks recipes in the recipe book, one at a time or all of them with *. Locking a recipe doesn't stop anyone crafting it unless the game rule limited_crafting is on. That rule is off by default, and versions before 1.21.11 call it doLimitedCrafting.
All six commands need permission level 2.