Difference between revisions of "Command Data"

From wiki.vg
Jump to navigation Jump to search
m
(add "minecraft:available")
Line 470: Line 470:
 
   | <code>minecraft:available_sounds</code>
 
   | <code>minecraft:available_sounds</code>
 
   | Suggests all the available sounds.
 
   | Suggests all the available sounds.
 +
  |-
 +
  | <code>minecraft:available_biomes</code>
 +
  | Suggests all the available biomes.
 
   |-
 
   |-
 
   | <code>minecraft:summonable_entities</code>
 
   | <code>minecraft:summonable_entities</code>

Revision as of 13:06, 16 September 2021

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 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 Optional Identifier 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 Field 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 Declare Commands packet should stop immediately, as the structure of the remainder of the packet cannot be guessed.

Identifier Properties Description
brigadier:bool Boolean value (true or false, case-sensitive)
brigadier:double See below Double
brigadier:float See below Float
brigadier:integer See below Integer
brigadier:long See below Long
brigadier:string See below A string
minecraft:entity See below A selector, player name, or UUID.
minecraft:game_profile A player, online or not. Can also use a selector, which may match one or more players (but not entities).
minecraft:block_pos A location, represented as 3 numbers (which must be integers). May use relative locations with ~.
minecraft:column_pos A column location, represented as 3 numbers (which must be integers). May use relative locations with ~.
minecraft:vec3 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 ~.
minecraft:vec2 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 ~.
minecraft:block_state A block state, optionally including NBT and state information.
minecraft:block_predicate A block, or a block tag.
minecraft:item_stack An item, optionally including NBT.
minecraft:item_predicate An item, or an item tag.
minecraft:color A chat color. One of the names from Chat#Colors, or reset. Case-insensitive.
minecraft:component A JSON Chat component.
minecraft:message A regular message, potentially including selectors.
minecraft:nbt An NBT value, parsed using JSON-NBT rules.
minecraft:nbt_path A path within an NBT value, allowing for array and member accesses.
minecraft:objective A scoreboard objective.
minecraft:objective_criteria A single score criterion.
minecraft:operation A scoreboard operator.
minecraft:particle A particle effect (an identifier with extra information following it for specific particles, mirroring the Particle packet)
minecraft:rotation 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 ~.
minecraft:angle
minecraft:scoreboard_slot A scoreboard display position slot. list, sidebar, belowName, and sidebar.team.${color} for all chat colors (reset is not included)
minecraft:score_holder See below Something that can join a team. Allows selectors and *.
minecraft:swizzle A collection of up to 3 axes.
minecraft:team The name of a team. Parsed as an unquoted string.
minecraft:item_slot A name for an inventory slot.
minecraft:resource_location An Identifier.
minecraft:mob_effect A potion effect.
minecraft:function A function.
minecraft:entity_anchor The entity anchor related to the facing argument in the teleport command, is feet or eyes.
minecraft:range See below A range of values with a min and a max.
minecraft:int_range An integer range of values with a min and a max.
minecraft:float_range A floating-point range of values with a min and a max.
minecraft:item_enchantment Represents a item enchantment.
minecraft:entity_summon Represents an entity summon.
minecraft:dimension Represents a dimension.
minecraft:uuid Represents a UUID value.
minecraft:nbt_tag Represents a partial nbt tag, usable in data modify command.
minecraft:nbt_compound_tag Represents a full nbt tag.
minecraft:time Represents a time duration.
forge:modid Represents a mod identifier. Added by Minecraft Forge. Vanilla clients/servers do not support this parser.
forge:enum Represents a enum class to use for suggestion. Added by Minecraft Forge. Vanilla clients/servers do not support this parser.

Properties

brigadier:double

Specifies min and max values.

Name Type Description
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.

Name Type Description
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.

Name Type Description
Flags Byte
Min Optional integer Only if flags & 0x01. If not specified, defaults to Integer.MIN_VALUE (-2147483648)
Max Optional integer Only if flags & 0x02. If not specified, defaults to Integer.MAX_VALUE (2147483647)
brigadier:long

Specifies min and max values.

Name Type Description
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.

Value Name Description
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:range

A range of values with a min and a max.

Name Type Description
Decimals Boolean Whether decimal values are allowed.
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

Name Type Description
Class String Enum Class to use

Suggestions Types

Identifier Description
minecraft:ask_server Sends the Tab-Complete 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:available_biomes Suggests all the available biomes.
minecraft:summonable_entities Suggests all the summonable entities.

Example Graphs

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