/tag
< Commands
/tag| Permission level required |
|
|---|---|
| Restrictions |
Cheat only |
{
"title": "<code>/tag</code>",
"rows": [
{
"field": "\n* 2 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Java Edition\">(link to Java Edition article, displayed as JE) only</span></i>]</sup>\n* 1 <sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "(link to Options article, displayed as Cheat) only<sup class=\"noprint nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Controls scoreboard tags on individual entities. In Java Edition, the number of tags owned by an entity cannot exceed 1024.
Java Edition note: This is distinct from entity type tags, which are applied to entity types and can't be changed by commands.
Syntax
- Java Edition
tag <targets> add <name>- Adds a tag to the targets.
tag <targets> remove <name>- Removes a tag from the targets.
tag <targets> list- Lists all tags on the targets.
- Bedrock Edition
tag <entity: targets> add <name: string>- Adds a tag to the targets.
tag <entity: targets> remove <name: string>- Removes a tag from the targets.
tag <entity: targets> list- Lists all tags on the targets.
Arguments
JE: <targets>: entity
BE: entity: target: WildcardCommandSelector<Actor>
- Specifies the command's target.
- In Java Edition, must be a player name, a target selector or a UUID.
- In Bedrock Edition, must be either a target selector, a player name, or
*for all score holders.
JE: <name>: string
BE: name: string: basic_string
- Specifies the name of the tag to be added into or removed from the targets.
- Must be a string. In Java Edition, it must be in a single word (Allowed characters include:
-,+,.,_,A-Z,a-z, and0-9). In Bedrock Edition, it must be a single word that has no space or a double-quoted string (When quoted,\can be used to escape characters).
Result
| Command | Trigger | Java Edition | Bedrock Edition |
|---|---|---|---|
| Any | The command is incomplete, or any argument is not specified correctly. | Unparseable | Unparseable |
<targets> or player: target fails to resolve to one or more entities (named players must be online). | Failed | Failed | |
/tag ... add ... | All selected entities meet one or more of the following conditions:
| ||
/tag ... remove ... | There's no entity whose tag is removed. | ||
/tag ... list ... | There's no entity that has any tag. | Successful | |
| Any | Otherwise | Successful | |
Output
| Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
|---|---|---|---|---|---|
| Any | Java Edition | On fail | 0 | 0 | 0 |
/tag ... add ... | On success | 1 | 1 | the number of entities who get a new tag | |
/tag ... remove ... | On success | 1 | 1 | the number of entities whose tag is remove | |
/tag ... list | On success | 1 | 1 | the number of all tags the specified entities have | |
| Any | Bedrock Edition | On fail | 0 | N/A | N/A |
| On success | 1 | N/A | N/A |
History
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.13 | 17w45a | Added /tag. | |||||
| Bedrock Edition | |||||||
| 1.9 | beta 1.9.0.2 | Added /tag. | |||||
See also
/team