Minecraft:Commands/item
More actions
|
For the {{{Description}}} of the same name, see [[{{{Destination}}}]]. |
Script error: No such module "Exclusive". Template:Infobox command Manipulate or copy Minecraft:items in the inventories of Minecraft:blocks (Minecraft:chests, Minecraft:furnaces, etc.) or entities (players or Minecraft:mobs).
Syntax
item modify (block <pos>|entity <targets>) <slot> <modifier>- Modifies the items in the specified slot with the specified item modifier.
item replace (block <pos>|entity <targets>) <slot> with <item> [<count>]- Replaces the items in the specified slot with the specified items.
item replace (block <pos>|entity <targets>) <slot> from (block <sourcePos>|entity <sourceTarget>) <sourceSlot> [<modifier>]- Copies the source items to the target slot and optionally modifies it with the
modifier.
- Copies the source items to the target slot and optionally modifies it with the
Syntax displayed in various ways
Simplified tree: item ...... modify <TARGET> <slot> <modifier>... replace <TARGET> <slot>... with <item> [<count>]... from <SOURCE> <sourceSlot> [<modifier>]
- where substituted arguments are:
<TARGET>=(block <pos>|entity <targets>)<SOURCE>=(block <sourcePos>|entity <sourceTarget>)
Minimised: item (modify (block <pos>|entity <targets>) <slot> <modifier>|replace (block <pos>|entity <targets>) <slot> (with <item> [<count>]|from (block <sourcePos>|entity <sourceTarget>) <sourceSlot> [<modifier>]))
Maximised: item modify block <pos> <slot> <modifier>item modify entity <targets> <slot> <modifier>item replace block <pos> <slot> with <item> [<count>]item replace block <pos> <slot> from block <sourcePos> <sourceSlot> [<modifier>]item replace block <pos> <slot> from entity <sourceTarget> <sourceSlot> [<modifier>]item replace entity <targets> <slot> with <item> [<count>]item replace entity <targets> <slot> from block <sourcePos> <sourceSlot> [<modifier>]item replace entity <targets> <slot> from entity <sourceTarget> <sourceSlot> [<modifier>]
Arguments
<pos>: block_pos
- Specifies the position of the block to be modified.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|block_pos}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<targets>: entity
- Specifies one or more entities to modify.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|entity}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<slot>: item_slot
- Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|item_slot}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<modifier>: loot_modifier
- Specifies the item modifier to apply on the chosen item.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|loot_modifier}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<item>: item_stack
- Specifies the item to be placed in the block or entity's inventory slot.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|item_stack}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<count>: integer
- Specifies the number of items to be placed in the block or entity's inventory slot.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|integer}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<sourcePos>: block_pos
- Specifies the position of the block to copy items from.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|block_pos}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<sourceTarget>: entity
- Specifies an entity to copy items from.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|entity}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<sourceSlot>: item_slot
- Specifies the inventory slot to copy the items from. Valid values depend on whether the source is block or an entity.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|item_slot}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
Result
Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table
Output
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On fail}}{{#vardefine:output1-{{#var:output-table-lines}}|0}}{{#vardefine:output2-{{#var:output-table-lines}}|0}}{{#vardefine:output3-{{#var:output-table-lines}}|0}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-editions-num|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-{{#var:output-editions-num}}|je}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|1}} Template:Output table Template:Output table
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
Examples
- To replace the items in the bottom-right slot of a single chest two block above with four spruce saplings:
/item replace block ~ ~2 ~ container.26 with minecraft:spruce_sapling 4
- To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
/item replace entity @p hotbar.8 with minecraft:spruce_sapling 4
- To replace the item in the offhand of the selected player with the item in their main hand:
/item replace entity @s weapon.offhand from entity @s weapon.mainhand
- To put a brown Minecraft:banner on a player's head
/item replace entity @s armor.head with minecraft:brown_banner
- To increase the count of the item in your main hand:
/item modify entity @s weapon.mainhand example:increase_count- file in a data pack:
data/example/item_modifier/increase_count.json<syntaxhighlight lang="json">{
"function": "minecraft:set_count", "count": 1, "add": true
}</syntaxhighlight>
- To increase the count of the item in your main hand without external files:
item modify entity @s weapon.mainhand {"function":"minecraft:set_count","count":1,"add":true}
- To put the item in your hand, on your head:
/item replace entity @s armor.head from entity @s weapon.mainhand
History
See also
- REDIRECT Template:Command
Template:Redr — can also replace items in a container's or mob's inventory, or modify the drop chances of armor and weapons
- REDIRECT Template:Command
Template:Redr — give items to players without specifying specific inventory slots or overwriting other items
- REDIRECT Template:Command
Template:Redr — The
- REDIRECT Template:Edition
Template:Rcat equivalent
de:Befehl/item es:Comandos/item ja:コマンド/item pt:Comandos/item ru:Команды консоли/item zh:命令/item