Difference between revisions of "Command Data"

From wiki.vg
Jump to navigation Jump to search
(→‎Parsers: I found this parser type "minecraft:angle" while looking through a ReplayMod TMCPR file. It does not have any additional properties. It appears to have been added in 1.16.)
 
(26 intermediate revisions by 14 users not shown)
Line 3: Line 3:
 
== Graph Structure ==
 
== Graph Structure ==
  
The graph consists of nodes of type <code>root</code>, <code>literal</code> and <code>argument</code>. A node may point to a number child nodes, or redirect to another node, or neither. The root node is nameless, and its children are literal nodes for familiar commands ("msg", "me", etc).  
+
The graph consists of nodes of type <code>root</code>, <code>literal</code> and <code>argument</code>. A node may point to a number of child nodes, or redirect to another node, or neither. The root node is nameless, and its children are literal nodes for familiar commands ("msg", "me", etc).  
  
 
Nodes are marked as executable if the node stack to this point constitutes a valid command. E.g. this is false for <code>/ban</code> but true for <code>/ban Dinnerbone</code> and <code>/ban Dinnerbone created this crazy format</code>.
 
Nodes are marked as executable if the node stack to this point constitutes a valid command. E.g. this is false for <code>/ban</code> but true for <code>/ban Dinnerbone</code> and <code>/ban Dinnerbone created this crazy format</code>.
Line 17: Line 17:
 
  |-
 
  |-
 
  | [[ #Flags | Flags ]]
 
  | [[ #Flags | Flags ]]
  | Byte
+
  | {{Type|Byte}}
 
  | See below.
 
  | See below.
 
  |-
 
  |-
 
  | Children count
 
  | Children count
  | VarInt
+
  | {{Type|VarInt}}
 
  | Number of elements in the following array.
 
  | Number of elements in the following array.
 
  |-
 
  |-
 
  | Children
 
  | Children
  | Array of VarInt
+
  | {{Type|Array}} of {{Type|VarInt}}
 
  | Array of indices of child nodes.
 
  | Array of indices of child nodes.
 
  |-
 
  |-
 
  | Redirect node
 
  | Redirect node
  | Optional VarInt
+
  | {{Type|Optional}} {{Type|VarInt}}
 
  | Only if <code>flags & 0x08</code>. Index of redirect node.
 
  | Only if <code>flags & 0x08</code>. Index of redirect node.
 
  |-
 
  |-
 
  | Name
 
  | Name
  | Optional String (32767)
+
  | {{Type|Optional}} {{Type|String}} (32767)
 
  | Only for <code>argument</code> and <code>literal</code> nodes.
 
  | Only for <code>argument</code> and <code>literal</code> nodes.
 
  |-
 
  |-
  | [[ #Parsers | Parser ]]
+
  | [[ #Parsers | Parser ID ]]
  | Optional Identifier
+
  | {{Type|Optional}} {{Type|VarInt}}
 
  | Only for <code>argument</code> nodes.
 
  | Only for <code>argument</code> nodes.
 
  |-
 
  |-
  | [[ #Properties | Properties ]]
+
  | Properties
  | Optional Varies
+
  | {{Type|Optional}} Varies
 
  | Only for <code>argument</code> nodes. Varies by parser.
 
  | Only for <code>argument</code> nodes. Varies by parser.
 
  |-
 
  |-
 
  | [[ #Suggestions_Types | Suggestions type ]]
 
  | [[ #Suggestions_Types | Suggestions type ]]
  | Optional Identifier
+
  | {{Type|Optional}} {{Type|Identifier}}
 
  | Only if <code>flags & 0x10</code>.
 
  | Only if <code>flags & 0x10</code>.
 
  |}
 
  |}
Line 52: Line 52:
  
 
{| class="wikitable"
 
{| class="wikitable"
! Bit mask
+
! Bit Mask
! Field Name
+
! Flag Name
 
! Notes
 
! Notes
 
|-
 
|-
Line 75: Line 75:
 
=== Parsers ===
 
=== Parsers ===
  
Clients are expected to implement all parsers, including properties (if any). If an unknown parser is encountered by a client, unpacking of the [[ Protocol#Declare_Commands | Declare Commands ]] packet should stop immediately, as the structure of the remainder of the packet cannot be guessed.
+
Clients are expected to implement all parsers, including properties (if any). If an unknown parser is encountered by a client, unpacking of the [[ Protocol#Commands | Commands ]] packet should stop immediately, as the structure of the remainder of the packet cannot be guessed.
 +
 
 +
Since 1.19, parsers are identified by their ID in the Node Format. Parsers (as well as parser IDs) are provided only for <code>argument</code> nodes. If properties for parser are not specified, then this parser has no properties and "Properties" section in Node Format contains no data.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Identifier
+
  ! Numeric ID
 +
! String Identifier
 
  ! Properties
 
  ! Properties
 
  ! Description
 
  ! Description
 
  |-
 
  |-
 +
| 0
 
  | <code>brigadier:bool</code>
 
  | <code>brigadier:bool</code>
  |  
+
  | N/A
 
  | Boolean value (<code>true</code> or <code>false</code>, case-sensitive)
 
  | Boolean value (<code>true</code> or <code>false</code>, case-sensitive)
 
  |-
 
  |-
 +
| 1
 +
| <code>brigadier:float</code>
 +
| [[ #brigadier:float | See below ]]
 +
| Float
 +
|-
 +
| 2
 
  | <code>brigadier:double</code>
 
  | <code>brigadier:double</code>
 
  | [[ #brigadier:double | See below ]]
 
  | [[ #brigadier:double | See below ]]
 
  | Double
 
  | Double
 
  |-
 
  |-
  | <code>brigadier:float</code>
+
  | 3
| [[ #brigadier:float | See below ]]
 
| Float
 
|-
 
 
  | <code>brigadier:integer</code>
 
  | <code>brigadier:integer</code>
 
  | [[ #brigadier:integer | See below ]]
 
  | [[ #brigadier:integer | See below ]]
 
  | Integer
 
  | Integer
 
  |-
 
  |-
 +
| 4
 +
| <code>brigadier:long</code>
 +
| [[ #brigadier:long | See below ]]
 +
| Long
 +
|-
 +
| 5
 
  | <code>brigadier:string</code>
 
  | <code>brigadier:string</code>
 
  | [[ #brigadier:string | See below ]]
 
  | [[ #brigadier:string | See below ]]
 
  | A string
 
  | A string
 
  |-
 
  |-
 +
| 6
 
  | <code>minecraft:entity</code>
 
  | <code>minecraft:entity</code>
 
  | [[ #minecraft:entity | See below ]]
 
  | [[ #minecraft:entity | See below ]]
 
  | A selector, player name, or UUID.
 
  | A selector, player name, or UUID.
 
  |-
 
  |-
 +
| 7
 
  | <code>minecraft:game_profile</code>
 
  | <code>minecraft:game_profile</code>
  |  
+
  | N/A
 
  | A player, online or not.  Can also use a selector, which may match one or more players (but not entities).
 
  | A player, online or not.  Can also use a selector, which may match one or more players (but not entities).
 
  |-
 
  |-
 +
| 8
 
  | <code>minecraft:block_pos</code>
 
  | <code>minecraft:block_pos</code>
  |  
+
  | N/A
 
  | A location, represented as 3 numbers (which must be integers).  May use relative locations with <code>~</code>.
 
  | A location, represented as 3 numbers (which must be integers).  May use relative locations with <code>~</code>.
 
  |-
 
  |-
 +
| 9
 
  | <code>minecraft:column_pos</code>
 
  | <code>minecraft:column_pos</code>
  |  
+
  | N/A
  | A column location, represented as 3 numbers (which must be integers).  May use relative locations with <code>~</code>.
+
  | A column location, represented as 2 numbers (which must be integers).  May use relative locations with <code>~</code>.
 
  |-
 
  |-
 +
| 10
 
  | <code>minecraft:vec3</code>
 
  | <code>minecraft:vec3</code>
  |  
+
  | N/A
 
  | A location, represented as 3 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified).  May use relative locations with <code>~</code>.
 
  | A location, represented as 3 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified).  May use relative locations with <code>~</code>.
 
  |-
 
  |-
 +
| 11
 
  | <code>minecraft:vec2</code>
 
  | <code>minecraft:vec2</code>
  |  
+
  | N/A
 
  | A location, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified).  May use relative locations with <code>~</code>.
 
  | A location, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified).  May use relative locations with <code>~</code>.
 
  |-
 
  |-
 +
| 12
 
  | <code>minecraft:block_state</code>
 
  | <code>minecraft:block_state</code>
  |  
+
  | N/A
 
  | A block state, optionally including NBT and state information.
 
  | A block state, optionally including NBT and state information.
 
  |-
 
  |-
 +
| 13
 
  | <code>minecraft:block_predicate</code>
 
  | <code>minecraft:block_predicate</code>
  |  
+
  | N/A
 
  | A block, or a block tag.
 
  | A block, or a block tag.
 
  |-
 
  |-
 +
| 14
 
  | <code>minecraft:item_stack</code>
 
  | <code>minecraft:item_stack</code>
  |  
+
  | N/A
 
  | An item, optionally including NBT.
 
  | An item, optionally including NBT.
 
  |-
 
  |-
 +
| 15
 
  | <code>minecraft:item_predicate</code>
 
  | <code>minecraft:item_predicate</code>
  |  
+
  | N/A
 
  | An item, or an item tag.
 
  | An item, or an item tag.
 
  |-
 
  |-
 +
| 16
 
  | <code>minecraft:color</code>
 
  | <code>minecraft:color</code>
  |  
+
  | N/A
  | A chat color.  One of the names from [[Chat#Colors]], or <code>reset</code>.  Case-insensitive.
+
  | A chat color.  One of the names from [[Text formatting#Colors]], or <code>reset</code>.  Case-insensitive.
 
  |-
 
  |-
 +
| 17
 
  | <code>minecraft:component</code>
 
  | <code>minecraft:component</code>
  |  
+
  | N/A
  | A JSON [[Chat]] component.
+
  | A JSON [[Text formatting#Text components|text component]].
 +
|-
 +
| 18
 +
| <code>minecraft:style</code>
 +
| N/A
 +
| A JSON object containing the [[Text formatting#Styling fields|text component styling fields]].
 
  |-
 
  |-
 +
| 19
 
  | <code>minecraft:message</code>
 
  | <code>minecraft:message</code>
  |  
+
  | N/A
 
  | A regular message, potentially including selectors.
 
  | A regular message, potentially including selectors.
 
  |-
 
  |-
 +
| 20
 
  | <code>minecraft:nbt</code>
 
  | <code>minecraft:nbt</code>
  |  
+
  | N/A
 
  | An NBT value, parsed using JSON-NBT rules.
 
  | An NBT value, parsed using JSON-NBT rules.
 
  |-
 
  |-
 +
| 21
 +
| <code>minecraft:nbt_tag</code>
 +
| N/A
 +
| Represents a partial nbt tag, usable in data modify command.
 +
|-
 +
| 22
 
  | <code>minecraft:nbt_path</code>
 
  | <code>minecraft:nbt_path</code>
  |  
+
  | N/A
 
  | A path within an NBT value, allowing for array and member accesses.
 
  | A path within an NBT value, allowing for array and member accesses.
 
  |-
 
  |-
 +
| 23
 
  | <code>minecraft:objective</code>
 
  | <code>minecraft:objective</code>
  |  
+
  | N/A
 
  | A scoreboard objective.
 
  | A scoreboard objective.
 
  |-
 
  |-
 +
| 24
 
  | <code>minecraft:objective_criteria</code>
 
  | <code>minecraft:objective_criteria</code>
  |  
+
  | N/A
 
  | A single score criterion.
 
  | A single score criterion.
 
  |-
 
  |-
 +
| 25
 
  | <code>minecraft:operation</code>
 
  | <code>minecraft:operation</code>
  |  
+
  | N/A
 
  | A scoreboard operator.
 
  | A scoreboard operator.
 
  |-
 
  |-
 +
| 26
 
  | <code>minecraft:particle</code>
 
  | <code>minecraft:particle</code>
 +
| N/A
 +
| A particle effect (an identifier with extra information following it for specific particles, mirroring the [[#Particle|Particle]] packet)
 +
|-
 +
| 27
 +
| <code>minecraft:angle</code>
 +
| N/A
 
  |  
 
  |  
| A particle effect (an identifier with extra information following it for specific particles, mirroring the [[#Particle|Particle]] packet)
 
 
  |-
 
  |-
 +
| 28
 
  | <code>minecraft:rotation</code>
 
  | <code>minecraft:rotation</code>
  |  
+
  | N/A
 
  | An angle, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified).  May use relative locations with <code>~</code>.
 
  | An angle, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified).  May use relative locations with <code>~</code>.
|
 
|-
 
| <code>minecraft:angle</code>
 
|
 
|
 
 
  |-
 
  |-
 +
| 29
 
  | <code>minecraft:scoreboard_slot</code>
 
  | <code>minecraft:scoreboard_slot</code>
  |  
+
  | N/A
 
  | A scoreboard display position slot.  <code>list</code>, <code>sidebar</code>, <code>belowName</code>, and <code>sidebar.team.${color}</code> for all chat colors (<code>reset</code> is not included)
 
  | A scoreboard display position slot.  <code>list</code>, <code>sidebar</code>, <code>belowName</code>, and <code>sidebar.team.${color}</code> for all chat colors (<code>reset</code> is not included)
 
  |-
 
  |-
 +
| 30
 
  | <code>minecraft:score_holder</code>
 
  | <code>minecraft:score_holder</code>
 
  | [[ #minecraft:score_holder | See below ]]
 
  | [[ #minecraft:score_holder | See below ]]
 
  | Something that can join a team.  Allows selectors and <code>*</code>.
 
  | Something that can join a team.  Allows selectors and <code>*</code>.
 
  |-
 
  |-
 +
| 31
 
  | <code>minecraft:swizzle</code>
 
  | <code>minecraft:swizzle</code>
  |  
+
  | N/A
 
  | A collection of up to 3 axes.
 
  | A collection of up to 3 axes.
 
  |-
 
  |-
 +
| 32
 
  | <code>minecraft:team</code>
 
  | <code>minecraft:team</code>
  |  
+
  | N/A
 
  | The name of a team.  Parsed as an unquoted string.
 
  | The name of a team.  Parsed as an unquoted string.
 
  |-
 
  |-
 +
| 33
 
  | <code>minecraft:item_slot</code>
 
  | <code>minecraft:item_slot</code>
  |  
+
  | N/A
 
  | A name for an inventory slot.
 
  | A name for an inventory slot.
 
  |-
 
  |-
 +
| 34
 
  | <code>minecraft:resource_location</code>
 
  | <code>minecraft:resource_location</code>
  |  
+
  | N/A
 
  | An Identifier.
 
  | An Identifier.
 
  |-
 
  |-
  | <code>minecraft:mob_effect</code>
+
  | 35
|
 
| A potion effect.
 
|-
 
 
  | <code>minecraft:function</code>
 
  | <code>minecraft:function</code>
  |  
+
  | N/A
 
  | A function.
 
  | A function.
 
  |-
 
  |-
 +
| 36
 
  | <code>minecraft:entity_anchor</code>
 
  | <code>minecraft:entity_anchor</code>
  |  
+
  | N/A
 
  | The entity anchor related to the facing argument in the teleport command, is feet or eyes.
 
  | The entity anchor related to the facing argument in the teleport command, is feet or eyes.
 
  |-
 
  |-
  | <code>minecraft:range</code>
+
  | 37
| [[ #minecraft:range | See below ]]
 
| A range of values with a min and a max.
 
|-
 
 
  | <code>minecraft:int_range</code>
 
  | <code>minecraft:int_range</code>
  |
+
  | N/A
 
  | An integer range of values with a min and a max.
 
  | An integer range of values with a min and a max.
 
  |-
 
  |-
 +
| 38
 
  | <code>minecraft:float_range</code>
 
  | <code>minecraft:float_range</code>
  |
+
  | N/A
 
  | A floating-point range of values with a min and a max.
 
  | A floating-point range of values with a min and a max.
 
  |-
 
  |-
  | <code>minecraft:item_enchantment</code>
+
| 39
  |  
+
| <code>minecraft:dimension</code>
  | Represents a item enchantment.
+
| N/A
 +
| Represents a dimension.
 +
|-
 +
| 40
 +
  | <code>minecraft:gamemode</code>
 +
  | N/A
 +
  | Represents a gamemode. (<code>survival</code>, <code>creative</code>, <code>adventure</code> or <code>spectator</code>)
 +
|-
 +
| 41
 +
| <code>minecraft:time</code>
 +
| [[ #minecraft:time | See below ]]
 +
| Represents a time duration.
 +
|-
 +
| 42
 +
| <code>minecraft:resource_or_tag</code>
 +
| [[ #minecraft:resource_or_tag | See below ]]
 +
| An identifier or a tag name for a registry.
 +
|-
 +
| 43
 +
| <code>minecraft:resource_or_tag_key</code>
 +
| [[ #minecraft:resource_or_tag_key | See below ]]
 +
| An identifier or a tag name for a registry.
 +
|-
 +
| 44
 +
| <code>minecraft:resource</code>
 +
| [[ #minecraft:resource | See below ]]
 +
| An identifier for a registry.
 +
|-
 +
| 45
 +
| <code>minecraft:resource_key</code>
 +
| [[ #minecraft:resource_key | See below ]]
 +
| An identifier for a registry.
 +
|-
 +
| 46
 +
| <code>minecraft:template_mirror</code>
 +
| N/A
 +
| Mirror type (<code>none</code>, <code>left_right</code> or <code>front_back</code>)
 
  |-
 
  |-
  | <code>minecraft:entity_summon</code>
+
| 47
  |  
+
  | <code>minecraft:template_rotation</code>
  | Represents an entity summon.
+
  | N/A
 +
  | Rotation type (<code>none</code>, <code>clockwise_90</code>, <code>180</code> or <code>counterclockwise_90</code>)
 
  |-
 
  |-
  | <code>minecraft:dimension</code>
+
| 48
  |  
+
  | <code>minecraft:heightmap</code>
  | Represents a dimension.
+
  | N/A
 +
  | Post-worldgen heightmap type (<code>motion_blocking</code>, <code>motion_blocking_no_leaves</code>, <code>ocean_floor</code> and <code>world_surface</code>)
 
  |-
 
  |-
 +
| 49
 
  | <code>minecraft:uuid</code>
 
  | <code>minecraft:uuid</code>
  |  
+
  | N/A
 
  | Represents a UUID value.
 
  | Represents a UUID value.
 
  |-
 
  |-
  | <code>minecraft:nbt_tag</code>
+
  | ?
|
+
  | <code>forge:modid</code>
| Represents a partial nbt tag, usable in data modify command.
+
  | Unknown
|-
+
  | Represents a mod identifier. Added by Minecraft Forge. Vanilla clients/servers do not support this parser.
  | <code>minecraft:nbt_compound_tag</code>
 
  |  
 
  | Represents a full nbt tag.
 
|-
 
| <code>minecraft:time</code>
 
|
 
| Represents a time duration.
 
 
  |-
 
  |-
 +
| ?
 
  | <code>forge:enum</code>
 
  | <code>forge:enum</code>
  |  
+
  | Unknown
 
  | Represents a enum class to use for suggestion. Added by Minecraft Forge. Vanilla clients/servers do not support this parser.
 
  | Represents a enum class to use for suggestion. Added by Minecraft Forge. Vanilla clients/servers do not support this parser.
 
  |}
 
  |}
  
==== Properties ====
+
==== <code>brigadier:double</code> ====
 
 
===== <code>brigadier:double</code> =====
 
  
 
Specifies min and max values.
 
Specifies min and max values.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Name
+
  ! Field Name
  ! Type
+
  ! Field Type
  ! Description
+
  ! Notes
 
  |-
 
  |-
 
  | Flags
 
  | Flags
  | Byte
+
  | {{Type|Byte}}
 
  |
 
  |
 
  |-
 
  |-
 
  | Min
 
  | Min
  | Optional double
+
  | {{Type|Optional}} {{Type|Double}}
 
  | Only if flags & 0x01.  If not specified, defaults to <code>-Double.MAX_VALUE</code> (≈ -1.7976931348623157E307)
 
  | Only if flags & 0x01.  If not specified, defaults to <code>-Double.MAX_VALUE</code> (≈ -1.7976931348623157E307)
 
  |-
 
  |-
 
  | Max
 
  | Max
  | Optional double
+
  | {{Type|Optional}} {{Type|Double}}
 
  | Only if flags & 0x02.  If not specified, defaults to <code>Double.MAX_VALUE</code> (≈ 1.7976931348623157E307)
 
  | Only if flags & 0x02.  If not specified, defaults to <code>Double.MAX_VALUE</code> (≈ 1.7976931348623157E307)
 
  |}
 
  |}
+
 
===== <code>brigadier:float</code> =====
+
==== <code>brigadier:float</code> ====
  
 
Specifies min and max values.
 
Specifies min and max values.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Name
+
  ! Field Name
  ! Type
+
  ! Field Type
  ! Description
+
  ! Notes
 
  |-
 
  |-
 
  | Flags
 
  | Flags
  | Byte
+
  | {{Type|Byte}}
 
  |
 
  |
 
  |-
 
  |-
 
  | Min
 
  | Min
  | Optional float
+
  | {{Type|Optional}} {{Type|Float}}
 
  | Only if flags & 0x01.  If not specified, defaults to <code>-Float.MAX_VALUE</code> (≈ 3.4028235E38)
 
  | Only if flags & 0x01.  If not specified, defaults to <code>-Float.MAX_VALUE</code> (≈ 3.4028235E38)
 
  |-
 
  |-
 
  | Max
 
  | Max
  | Optional float
+
  | {{Type|Optional}} {{Type|Float}}
 
  | Only if flags & 0x02.  If not specified, defaults to <code>Float.MAX_VALUE</code> (≈ 3.4028235E38)
 
  | Only if flags & 0x02.  If not specified, defaults to <code>Float.MAX_VALUE</code> (≈ 3.4028235E38)
 
  |}
 
  |}
 
   
 
   
===== <code>brigadier:integer</code> =====
+
==== <code>brigadier:integer</code> ====
  
 
Specifies min and max values.
 
Specifies min and max values.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Name
+
  ! Field Name
  ! Type
+
  ! Field Type
  ! Description
+
  ! Notes
 
  |-
 
  |-
 
  | Flags
 
  | Flags
  | Byte
+
  | {{Type|Byte}}
 
  |
 
  |
 
  |-
 
  |-
 
  | Min
 
  | Min
  | Optional integer
+
  | {{Type|Optional}} {{Type|Int}}
 
  | Only if flags & 0x01.  If not specified, defaults to <code>Integer.MIN_VALUE</code>  (-2147483648)
 
  | Only if flags & 0x01.  If not specified, defaults to <code>Integer.MIN_VALUE</code>  (-2147483648)
 
  |-
 
  |-
 
  | Max
 
  | Max
  | Optional integer
+
  | {{Type|Optional}} {{Type|Int}}
 
  | Only if flags & 0x02.  If not specified, defaults to <code>Integer.MAX_VALUE</code>  (2147483647)
 
  | Only if flags & 0x02.  If not specified, defaults to <code>Integer.MAX_VALUE</code>  (2147483647)
 
  |}
 
  |}
  
===== <code>brigadier:string</code> =====
+
==== <code>brigadier:long</code> ====
 +
 
 +
Specifies min and max values.
 +
 
 +
{| class="wikitable"
 +
! Field Name
 +
! Field Type
 +
! Notes
 +
|-
 +
| Flags
 +
| {{Type|Byte}}
 +
|
 +
|-
 +
| Min
 +
| {{Type|Optional}} {{Type|Long}}
 +
| Only if flags & 0x01.  If not specified, defaults to <code>Long.MIN_VALUE</code>  (−9,223,372,036,854,775,808)
 +
|-
 +
| Max
 +
| {{Type|Optional}} {{Type|Long}}
 +
| Only if flags & 0x02.  If not specified, defaults to <code>Long.MAX_VALUE</code>  (9,223,372,036,854,775,807)
 +
|}
 +
 
 +
==== <code>brigadier:string</code> ====
  
A VarInt enum.
+
A {{Type|VarInt}} {{Type|Enum}}.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Value
+
  ! Field Name
  ! Name
+
  ! Field Type
  ! Description
+
  ! Notes
 
  |-
 
  |-
 
  | 0
 
  | 0
Line 358: Line 456:
 
  |}
 
  |}
  
===== <code>minecraft:entity</code> =====
+
==== <code>minecraft:entity</code> ====
  
 
Has a single flags byte.
 
Has a single flags byte.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Bit mask
+
  ! Bit Mask
 
  ! Meaning
 
  ! Meaning
 
  |-
 
  |-
Line 373: Line 471:
 
  |}
 
  |}
  
===== <code>minecraft:score_holder</code> =====
+
==== <code>minecraft:score_holder</code> ====
  
Has a single flags byte:
+
Has a single flags byte.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Bit mask
+
  ! Bit Mask
 
  ! Meaning
 
  ! Meaning
 
  |-
 
  |-
Line 385: Line 483:
 
  |}
 
  |}
  
===== <code>minecraft:range</code> =====
+
==== <code>minecraft:time</code> ====
 +
 
 +
{| class="wikitable"
 +
! Field Name
 +
! Field Type
 +
! Notes
 +
|-
 +
| Min
 +
| {{Type|Int}}
 +
| Minimum duration in ticks
 +
|}
 +
 
 +
==== <code>minecraft:resource_or_tag</code> ====
 +
 
 +
Has a single identifier.
 +
 
 +
{| class="wikitable"
 +
! Field Name
 +
! Field Type
 +
! Notes
 +
|-
 +
| Registry
 +
| {{Type|Identifier}}
 +
| The registry from where suggestions will be sourced from.
 +
|}
 +
 
 +
==== <code>minecraft:resource_or_tag_key</code> ====
 +
 
 +
Has a single identifier.
 +
 
 +
{| class="wikitable"
 +
! Field Name
 +
! Field Type
 +
! Notes
 +
|-
 +
| Registry
 +
| {{Type|Identifier}}
 +
| The registry from where suggestions will be sourced from.
 +
|}
 +
 
 +
==== <code>minecraft:resource</code> ====
  
A range of values with a min and a max.
+
Has a single identifier.
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Name
+
  ! Field Name
  ! Type
+
  ! Field Type
  ! Description
+
  ! Notes
 +
|-
 +
| Registry
 +
| {{Type|Identifier}}
 +
| The registry from where suggestions will be sourced from.
 +
|}
 +
 
 +
==== <code>minecraft:resource_key</code> ====
 +
 
 +
Has a single identifier.
 +
 
 +
{| class="wikitable"
 +
! Field Name
 +
! Field Type
 +
! Notes
 
  |-
 
  |-
  | Decimals
+
  | Registry
  | Boolean
+
  | {{Type|Identifier}}
  | Whether decimal values are allowed.
+
  | The registry from where suggestions will be sourced from.
 
  |}
 
  |}
  
===== <code>forge:enum</code> =====
+
==== <code>forge:modid</code> ====
 +
Added by Minecraft Forge, vanilla clients/servers do not have this.
  
Added by Minecraft Forge vanilla clients/servers do not have this.
+
* Registered in https://github.com/MinecraftForge/MinecraftForge/blob/19f8d2a7937dc7968ecbef2f9785687193fcd210/src/main/java/net/minecraftforge/common/ForgeMod.java#L175
 +
* Serialized in https://github.com/MinecraftForge/MinecraftForge/blob/9177ac1b2e326a3acffaf476eeff28a1cf9a637f/src/main/java/net/minecraftforge/server/command/ModIdArgument.java
 +
 
 +
==== <code>forge:enum</code> ====
 +
 
 +
Added by Minecraft Forge, vanilla clients/servers do not have this.
 
Enum class to use for suggestions.  
 
Enum class to use for suggestions.  
 
The value is literally as is fed into the java method Class.forName
 
The value is literally as is fed into the java method Class.forName
Line 407: Line 565:
  
 
{| class="wikitable"
 
{| class="wikitable"
  ! Name
+
  ! Field Name
  ! Type
+
  ! Field Type
  ! Description
+
  ! Notes
 
  |-
 
  |-
 
  | Class
 
  | Class
  | String
+
  | {{Type|String}}
 
  | Enum Class to use
 
  | Enum Class to use
 
  |}
 
  |}
 +
 +
* Registered in https://github.com/MinecraftForge/MinecraftForge/blob/19f8d2a7937dc7968ecbef2f9785687193fcd210/src/main/java/net/minecraftforge/common/ForgeMod.java#L175
 +
* Serialized in https://github.com/MinecraftForge/MinecraftForge/blob/bca20ace4ecb1da07806c8fc6c749826c3bd57e1/src/main/java/net/minecraftforge/server/command/EnumArgument.java
  
 
=== Suggestions Types ===
 
=== Suggestions Types ===
 +
 +
If the provided suggestion type is not recognized by Notchian client, it will use <code>minecraft:ask_server</code>.
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 423: Line 586:
 
   |-
 
   |-
 
   | <code>minecraft:ask_server</code>
 
   | <code>minecraft:ask_server</code>
   | Sends the [[ Protocol#Tab-Complete_(serverbound) | Tab-Complete ]] packet to the server to request tab completions.
+
   | Sends the [[ Protocol#Command%20Suggestions%20Request | Command Suggestions Request ]] packet to the server to request tab completions.
 
   |-
 
   |-
 
   | <code>minecraft:all_recipes</code>
 
   | <code>minecraft:all_recipes</code>
Line 439: Line 602:
 
[[File:Command_graph_18w22c.png|thumb|center|Command graph from 18w22c. Executable nodes are shown in green; redirects are dashed.]]
 
[[File:Command_graph_18w22c.png|thumb|center|Command graph from 18w22c. Executable nodes are shown in green; redirects are dashed.]]
  
 +
[[Category:Protocol Details]]
 
[[Category:Minecraft Modern]]
 
[[Category:Minecraft Modern]]

Latest revision as of 18:46, 26 February 2024

From Minecraft 1.13, the Command Graph data structure defines commands which can be used in chat or in command blocks, and how they're parsed.

Graph Structure

The graph consists of nodes of type root, literal and argument. A node may point to a number of child nodes, or redirect to another node, or neither. The root node is nameless, and its children are literal nodes for familiar commands ("msg", "me", etc).

Nodes are marked as executable if the node stack to this point constitutes a valid command. E.g. this is false for /ban but true for /ban Dinnerbone and /ban Dinnerbone created this crazy format.

When including redirects, this structure is a directed graph that may include cycles (e.g. consider /execute run execute run execute ...). When excluding redirects, the structure no longer contains cycles but may still not be a tree, as a node may have multiple parents.

Node Format

Field Name Field Type Notes
Flags Byte See below.
Children count VarInt Number of elements in the following array.
Children Array of VarInt Array of indices of child nodes.
Redirect node Optional VarInt Only if flags & 0x08. Index of redirect node.
Name Optional String (32767) Only for argument and literal nodes.
Parser ID Optional VarInt Only for argument nodes.
Properties Optional Varies Only for argument nodes. Varies by parser.
Suggestions type Optional Identifier Only if flags & 0x10.

Flags

Bit Mask Flag Name Notes
0x03 Node type 0: root, 1: literal, 2: argument. 3 is not used.
0x04 Is executable Set if the node stack to this point constitutes a valid command.
0x08 Has redirect Set if the node redirects to another node.
0x10 Has suggestions type Only present for argument nodes.

Parsers

Clients are expected to implement all parsers, including properties (if any). If an unknown parser is encountered by a client, unpacking of the Commands packet should stop immediately, as the structure of the remainder of the packet cannot be guessed.

Since 1.19, parsers are identified by their ID in the Node Format. Parsers (as well as parser IDs) are provided only for argument nodes. If properties for parser are not specified, then this parser has no properties and "Properties" section in Node Format contains no data.

Numeric ID String Identifier Properties Description
0 brigadier:bool N/A Boolean value (true or false, case-sensitive)
1 brigadier:float See below Float
2 brigadier:double See below Double
3 brigadier:integer See below Integer
4 brigadier:long See below Long
5 brigadier:string See below A string
6 minecraft:entity See below A selector, player name, or UUID.
7 minecraft:game_profile N/A A player, online or not. Can also use a selector, which may match one or more players (but not entities).
8 minecraft:block_pos N/A A location, represented as 3 numbers (which must be integers). May use relative locations with ~.
9 minecraft:column_pos N/A A column location, represented as 2 numbers (which must be integers). May use relative locations with ~.
10 minecraft:vec3 N/A A location, represented as 3 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified). May use relative locations with ~.
11 minecraft:vec2 N/A A location, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified). May use relative locations with ~.
12 minecraft:block_state N/A A block state, optionally including NBT and state information.
13 minecraft:block_predicate N/A A block, or a block tag.
14 minecraft:item_stack N/A An item, optionally including NBT.
15 minecraft:item_predicate N/A An item, or an item tag.
16 minecraft:color N/A A chat color. One of the names from Text formatting#Colors, or reset. Case-insensitive.
17 minecraft:component N/A A JSON text component.
18 minecraft:style N/A A JSON object containing the text component styling fields.
19 minecraft:message N/A A regular message, potentially including selectors.
20 minecraft:nbt N/A An NBT value, parsed using JSON-NBT rules.
21 minecraft:nbt_tag N/A Represents a partial nbt tag, usable in data modify command.
22 minecraft:nbt_path N/A A path within an NBT value, allowing for array and member accesses.
23 minecraft:objective N/A A scoreboard objective.
24 minecraft:objective_criteria N/A A single score criterion.
25 minecraft:operation N/A A scoreboard operator.
26 minecraft:particle N/A A particle effect (an identifier with extra information following it for specific particles, mirroring the Particle packet)
27 minecraft:angle N/A
28 minecraft:rotation N/A An angle, represented as 2 numbers (which may have a decimal point, but will be moved to the center of a block if none is specified). May use relative locations with ~.
29 minecraft:scoreboard_slot N/A A scoreboard display position slot. list, sidebar, belowName, and sidebar.team.${color} for all chat colors (reset is not included)
30 minecraft:score_holder See below Something that can join a team. Allows selectors and *.
31 minecraft:swizzle N/A A collection of up to 3 axes.
32 minecraft:team N/A The name of a team. Parsed as an unquoted string.
33 minecraft:item_slot N/A A name for an inventory slot.
34 minecraft:resource_location N/A An Identifier.
35 minecraft:function N/A A function.
36 minecraft:entity_anchor N/A The entity anchor related to the facing argument in the teleport command, is feet or eyes.
37 minecraft:int_range N/A An integer range of values with a min and a max.
38 minecraft:float_range N/A A floating-point range of values with a min and a max.
39 minecraft:dimension N/A Represents a dimension.
40 minecraft:gamemode N/A Represents a gamemode. (survival, creative, adventure or spectator)
41 minecraft:time See below Represents a time duration.
42 minecraft:resource_or_tag See below An identifier or a tag name for a registry.
43 minecraft:resource_or_tag_key See below An identifier or a tag name for a registry.
44 minecraft:resource See below An identifier for a registry.
45 minecraft:resource_key See below An identifier for a registry.
46 minecraft:template_mirror N/A Mirror type (none, left_right or front_back)
47 minecraft:template_rotation N/A Rotation type (none, clockwise_90, 180 or counterclockwise_90)
48 minecraft:heightmap N/A Post-worldgen heightmap type (motion_blocking, motion_blocking_no_leaves, ocean_floor and world_surface)
49 minecraft:uuid N/A Represents a UUID value.
? forge:modid Unknown Represents a mod identifier. Added by Minecraft Forge. Vanilla clients/servers do not support this parser.
? forge:enum Unknown Represents a enum class to use for suggestion. Added by Minecraft Forge. Vanilla clients/servers do not support this parser.

brigadier:double

Specifies min and max values.

Field Name Field Type Notes
Flags Byte
Min Optional Double Only if flags & 0x01. If not specified, defaults to -Double.MAX_VALUE (≈ -1.7976931348623157E307)
Max Optional Double Only if flags & 0x02. If not specified, defaults to Double.MAX_VALUE (≈ 1.7976931348623157E307)

brigadier:float

Specifies min and max values.

Field Name Field Type Notes
Flags Byte
Min Optional Float Only if flags & 0x01. If not specified, defaults to -Float.MAX_VALUE (≈ 3.4028235E38)
Max Optional Float Only if flags & 0x02. If not specified, defaults to Float.MAX_VALUE (≈ 3.4028235E38)

brigadier:integer

Specifies min and max values.

Field Name Field Type Notes
Flags Byte
Min Optional Int Only if flags & 0x01. If not specified, defaults to Integer.MIN_VALUE (-2147483648)
Max Optional Int Only if flags & 0x02. If not specified, defaults to Integer.MAX_VALUE (2147483647)

brigadier:long

Specifies min and max values.

Field Name Field Type Notes
Flags Byte
Min Optional Long Only if flags & 0x01. If not specified, defaults to Long.MIN_VALUE (−9,223,372,036,854,775,808)
Max Optional Long Only if flags & 0x02. If not specified, defaults to Long.MAX_VALUE (9,223,372,036,854,775,807)

brigadier:string

A VarInt Enum.

Field Name Field Type Notes
0 SINGLE_WORD Reads a single word
1 QUOTABLE_PHRASE If it starts with a ", keeps reading until another " (allowing escaping with \). Otherwise behaves the same as SINGLE_WORD
2 GREEDY_PHRASE Reads the rest of the content after the cursor. Quotes will not be removed.

minecraft:entity

Has a single flags byte.

Bit Mask Meaning
0x01 If set, only allows a single entity/player
0x02 If set, only allows players

minecraft:score_holder

Has a single flags byte.

Bit Mask Meaning
0x01 If set, allows multiple.

minecraft:time

Field Name Field Type Notes
Min Int Minimum duration in ticks

minecraft:resource_or_tag

Has a single identifier.

Field Name Field Type Notes
Registry Identifier The registry from where suggestions will be sourced from.

minecraft:resource_or_tag_key

Has a single identifier.

Field Name Field Type Notes
Registry Identifier The registry from where suggestions will be sourced from.

minecraft:resource

Has a single identifier.

Field Name Field Type Notes
Registry Identifier The registry from where suggestions will be sourced from.

minecraft:resource_key

Has a single identifier.

Field Name Field Type Notes
Registry Identifier The registry from where suggestions will be sourced from.

forge:modid

Added by Minecraft Forge, vanilla clients/servers do not have this.

forge:enum

Added by Minecraft Forge, vanilla clients/servers do not have this. Enum class to use for suggestions. The value is literally as is fed into the java method Class.forName see net.minecraftforge.server.command.EnumArgument

Field Name Field Type Notes
Class String Enum Class to use

Suggestions Types

If the provided suggestion type is not recognized by Notchian client, it will use minecraft:ask_server.

Identifier Description
minecraft:ask_server Sends the Command Suggestions Request packet to the server to request tab completions.
minecraft:all_recipes Suggests all the available recipes.
minecraft:available_sounds Suggests all the available sounds.
minecraft:summonable_entities Suggests all the summonable entities.

Example Graphs

Command graph from 18w22c. Executable nodes are shown in green; redirects are dashed.