Commands/item

Manipulate or copy items in the inventories of blocks (chests, furnaces, etc.) or entities (players or mobs).
== Syntax ==
: item modify (block <pos>|entity <targets>) <slot> <modifier>
:: Modifies the items in the specified slot with the specified 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
:
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:
:
:
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 ==
: Specifies the position of the block to be modified.
: 
: Specifies one or more entities to modify.
: 
: Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
: 
: Specifies the item modifier to apply on the chosen item.
: 
: Specifies the item 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.
: 
: Specifies the position of the block to copy items from.
: 
: Specifies an entity to copy items from.
: 
: Specifies the inventory slot to copy the items from. Valid values depend on whether the source is block or an entity. See <slot> argument above for more information.
== Result ==
== Output ==
== 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 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 datapack: data/example/item_modifiers/increase_count.json{
 "function": "minecraft:set_count",
 "count": 1,
 "add": true
}
== History ==
== See also ==
* — can also replace items in a container's or mob's inventory, or modify the drop chances of armor and weapons
* — give items to players without specifying specific inventory slots or overwriting other items
* — The equivalent
de:Befehl/item
es:Comandos/item
ja:コマンド/item
pt:Comandos/item
zh:命令/item