Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/item: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Remove broken links to missing pages
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
Line 1: Line 1:
{{about||the [[Minecraft:Bedrock Edition]] equivalent|Commands/replaceitem|other uses|Item (disambiguation)}}
{{about||the [[Minecraft:Bedrock Edition]] equivalent|Commands/replaceitem|other uses|Item (disambiguation)}}
{{Exclusive|Java}}
{{MC/Exclusive|Java}}
{{Infobox command
{{Infobox command
|name=item
|name=item
Line 54: Line 54:


== Arguments ==
== Arguments ==
{{argument|pos|block_pos}}
{{MC/Argument|pos|block_pos}}
: Specifies the position of the block to be modified.
: Specifies the position of the block to be modified.
: {{arg desc|je=block_pos}}
: {{MC/Arg desc|je=block_pos}}


{{argument|targets|entity}}
{{MC/Argument|targets|entity}}
: Specifies one or more entities to modify.
: Specifies one or more entities to modify.
: {{arg desc|je=entity|amount=multiple|type=entities}}
: {{MC/Arg desc|je=entity|amount=multiple|type=entities}}


{{argument|slot|item_slot}}
{{MC/Argument|slot|item_slot}}
: Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
: Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
: {{arg desc|je=item_slot}}
: {{MC/Arg desc|je=item_slot}}


{{argument|modifier|loot_modifier}}
{{MC/Argument|modifier|loot_modifier}}
: Specifies the item modifier to apply on the chosen item.
: Specifies the item modifier to apply on the chosen item.
: {{Arg desc|je=loot_modifier}}
: {{MC/Arg desc|je=loot_modifier}}


{{argument|item|item_stack}}
{{MC/Argument|item|item_stack}}
: Specifies the item to be placed in the block or entity's inventory slot.
: Specifies the item to be placed in the block or entity's inventory slot.
: {{arg desc|je=item_stack}}
: {{MC/Arg desc|je=item_stack}}


{{argument|count|integer}}
{{MC/Argument|count|integer}}
: Specifies the number of items to be placed in the block or entity's inventory slot.
: Specifies the number of items to be placed in the block or entity's inventory slot.
: {{arg desc|je=integer|min=1|max=99}}<!--unparseable if bigger than 99, failed if bigger than the max stack size-->
: {{MC/Arg desc|je=integer|min=1|max=99}}<!--unparseable if bigger than 99, failed if bigger than the max stack size-->


{{argument|sourcePos|block_pos}}
{{MC/Argument|sourcePos|block_pos}}
: Specifies the position of the block to copy items from.
: Specifies the position of the block to copy items from.
: {{arg desc|je=block_pos}}
: {{MC/Arg desc|je=block_pos}}


{{argument|sourceTarget|entity}}
{{MC/Argument|sourceTarget|entity}}
: Specifies an entity to copy items from.
: Specifies an entity to copy items from.
: {{arg desc|je=entity|amount=single}}
: {{MC/Arg desc|je=entity|amount=single}}


{{argument|sourceSlot|item_slot}}
{{MC/Argument|sourceSlot|item_slot}}
: Specifies the inventory slot to copy the items from. Valid values depend on whether the source is block or an entity.
: Specifies the inventory slot to copy the items from. Valid values depend on whether the source is block or an entity.
: {{arg desc|je=item_slot}}
: {{MC/Arg desc|je=item_slot}}


== Result ==
== Result ==
Line 114: Line 114:


== Output ==
== Output ==
{{Output table}}
{{MC/Output table}}
{{Output table|edition=je|On fail|0|0|0}}
{{MC/Output table|edition=je|On fail|0|0|0}}
{{Output table|cmd=/item (modify{{!}}replace) block ...|On success|1|1|1}}
{{Output table|cmd=/item (modify{{!}}replace) block ...|On success|1|1|1}}
{{Output table|cmd=/item (modify{{!}}replace) entity ...|On success|1|1|the number of entities whose items are successfully replaced}}
{{Output table|cmd=/item (modify{{!}}replace) entity ...|On success|1|1|the number of entities whose items are successfully replaced}}
{{Output table}}
{{MC/Output table}}


== Examples ==
== Examples ==
Line 143: Line 143:
== History ==
== History ==
{{HistoryTable
{{HistoryTable
|{{HistoryLine|java}}
|{{MC/HistoryLine|java}}
|{{HistoryLine||November 8, 2017|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-17w45a|A command called {{cmd|modifyitem|link=none}} was mentioned in snapshot's Java Edition 17w45a update log at minecraft.net. At first it was planned to replace {{cmd|enchant}}.}}
|{{HistoryLine||November 8, 2017|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-17w45a|A command called {{MC/Cmd|modifyitem|link=none}} was mentioned in snapshot's Java Edition 17w45a update log at minecraft.net. At first it was planned to replace {{MC/Cmd|enchant}}.}}
|{{HistoryLine||February 9, 2018|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-18w06a|In Java Edition 18w06a's update logs, Dinnerbone states that the team has shelved the {{cmd|modifyitem|link=none}} idea, but that it may be considered the future.}}
|{{HistoryLine||February 9, 2018|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-18w06a|In Java Edition 18w06a's update logs, Dinnerbone states that the team has shelved the {{MC/Cmd|modifyitem|link=none}} idea, but that it may be considered the future.}}
|{{HistoryLine||1.17|dev=20w46a|Added {{cmd|item|link=none}}, replacing {{cmd|replaceitem}} and reusing the idea of {{cmd|modifyitem|link=none}} through one of its arguments, <code>modify</code>, which in fact contains a similar functionality to {{cmd|enchant|link=none}}, as they use item modifiers capable of changing the specified item's enchantments.}}
|{{HistoryLine||1.17|dev=20w46a|Added {{MC/Cmd|item|link=none}}, replacing {{MC/Cmd|replaceitem}} and reusing the idea of {{MC/Cmd|modifyitem|link=none}} through one of its arguments, <code>modify</code>, which in fact contains a similar functionality to {{MC/Cmd|enchant|link=none}}, as they use item modifiers capable of changing the specified item's enchantments.}}
|{{HistoryLine|||dev=21w19a|Syntax of {{cmd|item|link=none}} has been changed.}}
|{{HistoryLine|||dev=21w19a|Syntax of {{MC/Cmd|item|link=none}} has been changed.}}
|{{HistoryLine||1.19|dev=Pre-release 1|Replacing the off-hand slot using {{cmd|item|link=none}} no longer produces a [[Minecraft:vibration]].<ref>{{bug|MC-250022}}</ref>}}
|{{HistoryLine||1.19|dev=Pre-release 1|Replacing the off-hand slot using {{MC/Cmd|item|link=none}} no longer produces a [[Minecraft:vibration]].<ref>{{bug|MC-250022}}</ref>}}
|{{HistoryLine||1.20.2|dev=23w31a|Can now replace items in [[Minecraft:jukebox]]es.
|{{MC/HistoryLine||1.20.2|dev=23w31a|Can now replace items in [[Minecraft:jukebox]]es.
|Can now remove items in chiseled bookshelves.}}
|Can now remove items in chiseled bookshelves.}}
}}
}}


== See also ==
== See also ==
* {{cmd|data}} — can also replace items in a container's or mob's inventory, or modify the drop chances of armor and weapons
* {{MC/Cmd|data}} — can also replace items in a container's or mob's inventory, or modify the drop chances of armor and weapons
* {{cmd|give}} — give items to players without specifying specific inventory slots or overwriting other items
* {{MC/Cmd|give}} — give items to players without specifying specific inventory slots or overwriting other items
* {{cmd|replaceitem}} — The {{el|be}} equivalent
* {{MC/Cmd|replaceitem}} — The {{MC/El|be}} equivalent


== Navigation ==
== Navigation ==
{{Navbox commands}}
{{MC/Navbox commands}}


de:Befehl/item
de:Befehl/item

Revision as of 20:11, 9 April 2026

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.

Syntax displayed in various ways

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

Template:HistoryTable

See also

  1. 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

  1. REDIRECT Template:Command

Template:Redr — give items to players without specifying specific inventory slots or overwriting other items

  1. REDIRECT Template:Command

Template:Redr — The

  1. REDIRECT Template:Edition

Template:Rcat equivalent

Navigation

All editions
Removed
Template:El only
Debug
Removed
Template:Els only
Template:El only
Removed
Template:El only
Removed
Template:Els only
Removed
Joke
Related

de:Befehl/item es:Comandos/item ja:コマンド/item pt:Comandos/item ru:Команды консоли/item zh:命令/item