Minecraft:Argument types: Difference between revisions
More actions
imported>VECthba |
Remove broken links to missing pages |
||
| Line 92: | Line 92: | ||
{{Arg desc|je=long}} | {{Arg desc|je=long}} | ||
Note: Although a long argument type is present in | Note: Although a long argument type is present in brigadier, it is not used by ''Minecraft''. | ||
Each long argument type may have a custom minimum and maximum value. | Each long argument type may have a custom minimum and maximum value. | ||
| Line 169: | Line 169: | ||
The format of block_predicate parameters is <code>''block_id''[''block_states'']{''data_tags''}</code>, in which block states and data tags can be omitted when they are not needed. | The format of block_predicate parameters is <code>''block_id''[''block_states'']{''data_tags''}</code>, in which block states and data tags can be omitted when they are not needed. | ||
* <code>block_id</code> is required, and it should be in the format of | * <code>block_id</code> is required, and it should be in the format of resource location(if namespace isn't set it defaults to <code>minecraft:</code>). | ||
** It can also be the resource location of a | ** It can also be the resource location of a block tag prefixed with <code>#</code>, such as <code>#minecraft:planks</code>. | ||
* | * Block states are inside <code>[]</code>, comma-separated and properties and values must be supported by the block or all blocks in the tag. They are optional. | ||
** <code>minecraft:stone[doesntexist=purpleberry]</code> is unparseable, because <code>stone</code> doesn't have <code>doesntexist</code>. | ** <code>minecraft:stone[doesntexist=purpleberry]</code> is unparseable, because <code>stone</code> doesn't have <code>doesntexist</code>. | ||
** <code>minecraft:redstone_wire[power=tuesday]</code> is unparseable, because <code>redstone_wire</code>'s <code>power</code> is a number between 0 and 15. | ** <code>minecraft:redstone_wire[power=tuesday]</code> is unparseable, because <code>redstone_wire</code>'s <code>power</code> is a number between 0 and 15. | ||
* | * Data tags are inside <code>{}</code>. They are optional. | ||
* When test for block, only the states provided are tested. | * When test for block, only the states provided are tested. | ||
** If a command tests for <code>redstone_wire[power=15]</code>, it checks only power, but ignores other states such as <code>north</code>. | ** If a command tests for <code>redstone_wire[power=15]</code>, it checks only power, but ignores other states such as <code>north</code>. | ||
| Line 192: | Line 192: | ||
The format of block_state parameters is <code>''block_id''[''block_states'']{''data_tags''}</code>, in which block states and data tags can be omitted when they are not needed. | The format of block_state parameters is <code>''block_id''[''block_states'']{''data_tags''}</code>, in which block states and data tags can be omitted when they are not needed. | ||
* <code>block_id</code> is required, and it should be in the format of | * <code>block_id</code> is required, and it should be in the format of resource location (if namespace isn't set it defaults to <code>minecraft:</code>). | ||
* | * Block states are inside <code>[]</code>, comma-separated and must be properties/values supported by the blocks. They are optional. | ||
** <code>minecraft:stone[doesntexist=purpleberry]</code> is unparseable, because <code>stone</code> doesn't have <code>doesntexist</code>. | ** <code>minecraft:stone[doesntexist=purpleberry]</code> is unparseable, because <code>stone</code> doesn't have <code>doesntexist</code>. | ||
** <code>minecraft:redstone_wire[power=tuesday]</code> is unparseable, because <code>redstone_wire</code>'s <code>power</code> is a number between 0 and 15. | ** <code>minecraft:redstone_wire[power=tuesday]</code> is unparseable, because <code>redstone_wire</code>'s <code>power</code> is a number between 0 and 15. | ||
* | * Data tags are inside <code>{}</code>. They are optional. | ||
* When placing blocks, any states provided are set, but anything omitted retain their default values, depending on the block type. | * When placing blocks, any states provided are set, but anything omitted retain their default values, depending on the block type. | ||
** If a command sets <code>redstone_wire[power=15]</code>, it is set <code>power</code> to 15, but <code>north</code> is a default value (in this case, set to <code>none</code>). | ** If a command sets <code>redstone_wire[power=15]</code>, it is set <code>power</code> to 15, but <code>north</code> is a default value (in this case, set to <code>none</code>). | ||
| Line 360: | Line 360: | ||
The format of item_predicate parameters is <code><''item_type''>[<''list of tests''>]</code>, in which the list of tests with <code>[]</code> can be omitted when not needed. | The format of item_predicate parameters is <code><''item_type''>[<''list of tests''>]</code>, in which the list of tests with <code>[]</code> can be omitted when not needed. | ||
* <code><''item_type''></code> is required. | * <code><''item_type''></code> is required. | ||
** It can be in the format of | ** It can be in the format of resource location (if namespace isn't set it defaults to <code>minecraft:</code>). | ||
** It can also be the resource location of a | ** It can also be the resource location of a block tag or item tag with the prefix of <code>#</code>, such as <code>#minecraft:planks</code>. | ||
** It can also be a wildcard character <code>*</code> to match any item type. | ** It can also be a wildcard character <code>*</code> to match any item type. | ||
* The list of tests is optional. Test entries are inside <code>[]</code> and separated with <code><''separator''></code>. | * The list of tests is optional. Test entries are inside <code>[]</code> and separated with <code><''separator''></code>. | ||
* A test entry can be: | * A test entry can be: | ||
** <code><''component_id''></code> - Checks if a component exists. | ** <code><''component_id''></code> - Checks if a component exists. | ||
*** <code><''component_id''></code> is the ID of a | *** <code><''component_id''></code> is the ID of a data component. | ||
** <code><''component_id''>=<''value''></code> - Matches exact value of a component. | ** <code><''component_id''>=<''value''></code> - Matches exact value of a component. | ||
*** <code><''value''></code> is a representation of component value in SNBT format. | *** <code><''value''></code> is a representation of component value in SNBT format. | ||
** <code><''predicate_id''>~<''value''></code> - Checks an item sub-predicate | ** <code><''predicate_id''>~<''value''></code> - Checks an item sub-predicate | ||
*** <code><''predicate_id''></code> is the ID of an | *** <code><''predicate_id''></code> is the ID of an item sub-predicate. | ||
*** <code><''value''></code> is a representation of item sub-predicate in SNBT format. | *** <code><''value''></code> is a representation of item sub-predicate in SNBT format. | ||
*** Example: <code>*[damage~{durability:{min:3}}]</code> matches any stack with at least 3 uses left. | *** Example: <code>*[damage~{durability:{min:3}}]</code> matches any stack with at least 3 uses left. | ||
| Line 424: | Line 424: | ||
=== minecraft:item_stack === | === minecraft:item_stack === | ||
The format of item_stack is <code><''item_id''>[<''list of components''>]</code>, in which the list of components with <code>[]</code> can be omitted when not needed. | The format of item_stack is <code><''item_id''>[<''list of components''>]</code>, in which the list of components with <code>[]</code> can be omitted when not needed. | ||
* <code><''item_id''></code> is required, and it should be in the format of | * <code><''item_id''></code> is required, and it should be in the format of resource location (if namespace isn't set it defaults to <code>minecraft:</code>). | ||
* The list of | * The list of data components is optional. Data component entries are inside <code>[]</code> separated with <code>,</code>. | ||
** A data component entry can be: | ** A data component entry can be: | ||
*** <code><''component_id''>=<''value''></code> - Sets value of a data component. | *** <code><''component_id''>=<''value''></code> - Sets value of a data component. | ||
**** <code><''component_id''></code> is the ID of a | **** <code><''component_id''></code> is the ID of a data component. | ||
**** <code><''value''></code> is a representation of component value in SNBT format. | **** <code><''value''></code> is a representation of component value in SNBT format. | ||
*** <code>!<''component_id''></code> - Removes a default data component of the item. | *** <code>!<''component_id''></code> - Removes a default data component of the item. | ||
| Line 964: | Line 964: | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|java}} | |{{HistoryLine|java}} | ||
|{{HistoryLine||1.13|dev=17w45a| | |{{HistoryLine||1.13|dev=17w45a|Command arguments are now handled with Brigadier.}} | ||
|{{HistoryLine||1.14|dev=19w08a|Now allows single quotes for strings in commands.<ref>{{Link|url=https://github.com/Mojang/brigadier/pull/52|title=Allow single quote in strings by boq · Pull Request #52 |website=Mojang/brigadier – GitHub}}</ref>}} | |{{HistoryLine||1.14|dev=19w08a|Now allows single quotes for strings in commands.<ref>{{Link|url=https://github.com/Mojang/brigadier/pull/52|title=Allow single quote in strings by boq · Pull Request #52 |website=Mojang/brigadier – GitHub}}</ref>}} | ||
|{{HistoryLine||1.16|dev=20w17a|Added <code>minecraft:uuid</code> argument type.}} | |{{HistoryLine||1.16|dev=20w17a|Added <code>minecraft:uuid</code> argument type.}} | ||
| Line 978: | Line 978: | ||
|{{HistoryLine||1.19|dev=22w11a|Now <code>minecraft:item_predicate</code> and <code>minecraft:block_predicate</code> require tag to exist when parsing instead of executing.<ref>{{bug|MC-124984|resolution=Fixed}}</ref>}} | |{{HistoryLine||1.19|dev=22w11a|Now <code>minecraft:item_predicate</code> and <code>minecraft:block_predicate</code> require tag to exist when parsing instead of executing.<ref>{{bug|MC-124984|resolution=Fixed}}</ref>}} | ||
|{{HistoryLine|||dev=22w19a|Added <code>minecraft:template_mirror</code> and <code>minecraft:template_rotation</code> argument types.}} | |{{HistoryLine|||dev=22w19a|Added <code>minecraft:template_mirror</code> and <code>minecraft:template_rotation</code> argument types.}} | ||
|{{HistoryLine||1.19.3|dev=22w42a|Added <code>minecraft:resource_key</code> and <code>minecraft:resource_or_tag_key</code> argument types, which are used for reloadable registry entries (i.e. | |{{HistoryLine||1.19.3|dev=22w42a|Added <code>minecraft:resource_key</code> and <code>minecraft:resource_or_tag_key</code> argument types, which are used for reloadable registry entries (i.e. registered pack contents). | ||
|Now <code>minecraft:resource</code> and <code>minecraft:resource_or_tag</code> are used only for un-reloadable registry entries. | |Now <code>minecraft:resource</code> and <code>minecraft:resource_or_tag</code> are used only for un-reloadable registry entries. | ||
|Removed <code>minecraft:mob_effect</code>, <code>minecraft:entity_summon</code> and <code>minecraft:item_enchantment</code> argument types. Replaced by <code>minecraft:resource</code>.}} | |Removed <code>minecraft:mob_effect</code>, <code>minecraft:entity_summon</code> and <code>minecraft:item_enchantment</code> argument types. Replaced by <code>minecraft:resource</code>.}} | ||
| Line 997: | Line 997: | ||
[[Category:Commands]] | [[Category:Commands]] | ||
fr:Types d'arguments | |||
ja:引数の型 | |||
lzh:附項之類 | |||
pt:Tipos de argumentos | |||
ru:Типы аргументов | |||
zh:参数类型 | |||
Revision as of 15:19, 9 April 2026
This page contains a list of all command argument types. Template:TOC
Java Edition
brigadier:bool
Official examples
brigadier:double
Each double argument may have a custom minimum and maximum value.
Precision varies throughout number line; the maximum absolute value is about 1.8×10308.
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The maximum value of this double argument.
- Template:Nbt: The minimum value of this double argument.
brigadier:float
Each float argument type may have a custom minimum and maximum value.
Precision varies throughout number line; the maximum absolute value is about 3.4×1038.
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The maximum value of this float argument.
- Template:Nbt: The minimum value of this float argument.
brigadier:integer
Each integer argument type may have a custom minimum and maximum value.
Maximum range is from −(231) to (231 − 1), or from (−2,147,483,648) to (2,147,483,647).
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The maximum value of this integer argument.
- Template:Nbt: The minimum value of this integer argument.
brigadier:long
Note: Although a long argument type is present in brigadier, it is not used by Minecraft.
Each long argument type may have a custom minimum and maximum value.
Maximum range is from −(263) to (263−1), or from (−9,223,372,036,854,775,808) to (9,223,372,036,854,775,807).
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The maximum value of this long argument.
- Template:Nbt: The minimum value of this long argument.
brigadier:string
Each string argument type can accept either a single word (no spaces), a quotable phrase (either single word or quoted string), or a greedy phrase (taking the rest of the command as the string argument).
Official examples
Single word
Quotable phrase
Greedy phrase
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The type of this string argument. Can be Template:Cd, Template:Cd, or Template:Cd
minecraft:angle
Official examples
minecraft:block_pos
Official examples
minecraft:block_predicate
The format of block_predicate parameters is block_id[block_states]{data_tags}, in which block states and data tags can be omitted when they are not needed.
block_idis required, and it should be in the format of resource location(if namespace isn't set it defaults tominecraft:).- It can also be the resource location of a block tag prefixed with
#, such as#minecraft:planks.
- It can also be the resource location of a block tag prefixed with
- Block states are inside
[], comma-separated and properties and values must be supported by the block or all blocks in the tag. They are optional.minecraft:stone[doesntexist=purpleberry]is unparseable, becausestonedoesn't havedoesntexist.minecraft:redstone_wire[power=tuesday]is unparseable, becauseredstone_wire'spoweris a number between 0 and 15.
- Data tags are inside
{}. They are optional. - When test for block, only the states provided are tested.
- If a command tests for
redstone_wire[power=15], it checks only power, but ignores other states such asnorth.
- If a command tests for
Official examples
- Template:Cd
- Template:Cd
stone[foo=bar]- Template:Cd
#stone[foo=bar]{baz:nbt}
minecraft:block_state
The format of block_state parameters is block_id[block_states]{data_tags}, in which block states and data tags can be omitted when they are not needed.
block_idis required, and it should be in the format of resource location (if namespace isn't set it defaults tominecraft:).- Block states are inside
[], comma-separated and must be properties/values supported by the blocks. They are optional.minecraft:stone[doesntexist=purpleberry]is unparseable, becausestonedoesn't havedoesntexist.minecraft:redstone_wire[power=tuesday]is unparseable, becauseredstone_wire'spoweris a number between 0 and 15.
- Data tags are inside
{}. They are optional. - When placing blocks, any states provided are set, but anything omitted retain their default values, depending on the block type.
- If a command sets
redstone_wire[power=15], it is setpowerto 15, butnorthis a default value (in this case, set tonone).
- If a command sets
Official examples
- Template:Cd
- Template:Cd
stone[foo=bar]foo{bar:baz}
minecraft:color
Official examples
minecraft:column_pos
Official examples
minecraft:component
Official examples
minecraft:dimension
Official examples
minecraft:entity
Each entity argument may place limits on the number of entities (single/multiple) selected or the type of entities (player/any entity) selected.
Official examples
- Template:Cd
- Template:Cd
- Template:Cd
@e[type=foo]- Template:Cd
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The amount of entities that can be selected. Can be Template:Cd or Template:Cd.
- Template:Nbt: The target entity type. Can be Template:Cd or Template:Cd.
minecraft:entity_anchor
Official examples
minecraft:float_range
Official examples
minecraft:function
Official examples
minecraft:game_profile
Official examples
minecraft:gamemode
Official examples
minecraft:heightmap
Official examples
minecraft:int_range
Official examples
minecraft:item_predicate
The format of item_predicate parameters is <item_type>[<list of tests>], in which the list of tests with [] can be omitted when not needed.
<item_type>is required.- It can be in the format of resource location (if namespace isn't set it defaults to
minecraft:). - It can also be the resource location of a block tag or item tag with the prefix of
#, such as#minecraft:planks. - It can also be a wildcard character
*to match any item type.
- It can be in the format of resource location (if namespace isn't set it defaults to
- The list of tests is optional. Test entries are inside
[]and separated with<separator>. - A test entry can be:
<component_id>- Checks if a component exists.<component_id>is the ID of a data component.
<component_id>=<value>- Matches exact value of a component.<value>is a representation of component value in SNBT format.
<predicate_id>~<value>- Checks an item sub-predicate<predicate_id>is the ID of an item sub-predicate.<value>is a representation of item sub-predicate in SNBT format.- Example:
*[damage~{durability:{min:3}}]matches any stack with at least 3 uses left.
minecraft:count- Matches the stack size.count- Always passes.count=<positive_int>- Passes only when the stack size equals to the given value.count~<positive_int>- Passes only when the stack size equals to the given value.count~<int_range>- Passes when the stack size is in the specified range.<int_range>is an SNBT of{min:<min value>, max:<max value>}. Both min and max are optional.
- Example:
*[count~{max:2}]matches any stack with count <= 2.
- Any test entry above can be negated by prefixing with
!.- Example:
*[!count=1]matches any stack that has count other than 1.
- Example:
- A
<separator>can be:|- Logical OR.,- Logical AND.- Unlike most programming languages, the precedence of
|(Logical OR) is higher than,(Logical AND). - That means tests entries joined with | are treated as a single entry to check multiple alternatives.
- Example:
*[!damage|damage=0, count=1]looks for items without damage component or with 0 damage, and its count must be 1.
Official examples
minecraft:item_slot
Official examples
minecraft:item_slots
Official examples
minecraft:item_stack
The format of item_stack is <item_id>[<list of components>], in which the list of components with [] can be omitted when not needed.
<item_id>is required, and it should be in the format of resource location (if namespace isn't set it defaults tominecraft:).- The list of data components is optional. Data component entries are inside
[]separated with,.- A data component entry can be:
<component_id>=<value>- Sets value of a data component.<component_id>is the ID of a data component.<value>is a representation of component value in SNBT format.
!<component_id>- Removes a default data component of the item.
- A data component entry can be:
- When giving items, any components provided are set or removed, but anything omitted retain their default values, depending on the item type.
Official examples
- Template:Cd
- Template:Cd
stick{foo:bar}Template:Sic
minecraft:loot_modifier
Official examples
minecraft:loot_predicate
Official examples
minecraft:loot_table
Official examples
minecraft:message
Official examples
minecraft:nbt_compound_tag
Official examples
{}{foo:bar}
minecraft:nbt_path
An example
- Template:Cd
- Template:Cd
- <the first list element>
- <the second list element>
- Template:Cd
Official examples
- Template:Cd
- Template:Cd
- Template:Cd
- Template:Cd
[]{foo:bar}
minecraft:nbt_tag
Official examples
- Template:Cd
- Template:Cd
- Template:Cd
- Template:Cd
- Template:Cd
{foo:bar}
minecraft:objective
Official examples
minecraft:objective_criteria
Official examples
minecraft:operation
Official examples
minecraft:particle
Official examples
minecraft:resource
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The registry ID.
minecraft:resource_key
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The registry ID.
minecraft:resource_location
Template:Arg desc It is resolved during command execution into the unregistered content, or sent to the client to resolve into a client-side content.
Official examples
minecraft:resource_or_tag
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The registry ID.
minecraft:resource_or_tag_key
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The registry ID.
minecraft:resource_selector
Similar to resouce_location except enables the use of wildcard characters.
*- matches from 0 to any number of characters?- matches exactly one character
Official examples
- Template:Cd - matches all IDs
- Template:Cd - matches everthing in the
minecraftnamespace - Template:Cd - matches IDs in the
foldersubfolder in thecustomnamespace that end in_test_followed by one additional character.
minecraft:rotation
Official examples
minecraft:score_holder
Each score holder argument may specify if it can select only one score holder or multiple score holders.
Examples
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The amount of score holders that can be selected. Can be Template:Cd or Template:Cd.
minecraft:scoreboard_slot
Official examples
minecraft:style
Official examples
minecraft:swizzle
Official examples
minecraft:team
Official examples
minecraft:template_mirror
Official examples
minecraft:template_rotation
Official examples
minecraft:time
Official examples
JSON properties in command syntax output
- Template:Nbt: The root properties object.
- Template:Nbt: The minimum time in game ticks.
minecraft:uuid
Official examples
minecraft:vec2
Official examples
minecraft:vec3
Official examples
Removed
minecraft:entity_summon
Official examples
minecraft:item_enchantment
Official examples
minecraft:mob_effect
Official examples
Bedrock Edition
BlockStateCommandParam
Also known as BLOCK_STATE_ARRAY.
CommandCompareOperator
Also known as COMPAREOPERATOR.
CommandFilePath
Also known as PATHCOMMAND.
CommandIntegerRange
Also known as FULLINTEGERRANGE.
CommandMessage
Also known as MESSAGE_ROOT.
CommandOperator
Also known as OPERATOR.
CommandPosition
Also known as POSITION.
CommandPositionFloat
Also known as POSITION_FLOAT.
CommandRawText
Also known as RAWTEXT.
Template:Arg desc Template:AnchorTemplate:Anchor
CommandSelector<Actor> and CommandSelector<Player>
Also known as SELECTION.
CommandSelector<Actor> is used to specify entities. Template:Arg desc
CommandSelector<Player> is used to specify players. Template:Arg desc
CommandWildcardInt
Also known as WILDCARDINT.
Must be a 32-bit integer, or an asterisk (Template:Cd) to represent MIN_INT(-2,147,483,648),
float
Also known as VAL.
int
Also known as INT.
Json::Value
Also known as JSON_OBJECT.
RelativeFloat
Also known as RVAL.
Template:Arg desc Template:Anchor
std::basic_string
Also known as ID.
Template:Arg desc Template:Anchor
std::unique_ptr<Command>
Also known as SLASHCOMMAND.
Represents a complete command.
WildcardCommandSelector<Actor>
Also known as WILDCARDSELECTION.
Template:Arg desc Template:Anchor
Enum
Must be an unquoted string without space.
History
References
<references/>
fr:Types d'arguments ja:引数の型 lzh:附項之類 pt:Tipos de argumentos ru:Типы аргументов zh:参数类型