Minecraft Wiki

The Minecraft Wiki is no longer considered as official by Microsoft and therefore several changes are required to be made, including to the wiki's logo. Please read this announcement for more information.

READ MORE

Minecraft Wiki
Advertisement
Minecraft Wiki
Information icon.svg
This feature is exclusive to Java Edition. 
This article is missing information about /item modify. 
Please expand the article to include this information. Further details may exist on the talk page.
item
Permission level
required

2

Restrictions

None

Manipulate items in the inventories of blocks (chest, 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>]
Copys the source items to the target slot.

Syntax displayed in various ways

Arguments[]

<pos>: block_pos

Specifies the position of the block to be modified.
It must be a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation.

<targets>: entity

Specifies one or more entities to modify.
Must be a player name, a target selector or a UUID.

<slot>: item_slot

Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
For blocks, must be container.<slot_number> where <slot_number> or <slotId: int> is replaced with a number specifying the slot.
  • Chests, dispensers, droppers, hoppers, and trapped chests are numbered 0 for the top-left slot and then increase first horizontally, then vertically (so, for example, a chest's top row slots are numbered 0 to 8 from left to right). Double chests and double trapped chests are treated as two single container blocks.
  • A brewing stand's bottom slots are numbered 0 to 2 from left to right, its top slot is 3 and the fuel slot is 4.
  • A furnace's slots are numbered 0 for the input slot, 1 for the fuel slot, and 2 for the output slot.
Other blocks which hold items but don't have inventory GUIs (flower pots and jukeboxes) can only be changed with /data.
For entities, must be one of the following, where slot number or slot id is replaced with a number specifying the slot:
Slot Slot Numbers Restrictions
armor.chest armor stands, mobs, and players only (though not all mobs will show or make use of the items)
armor.feet
armor.head
armor.legs
weapon.mainhand
weapon.offhand
container.<slot_number> 0–53 players, item frames (slot 0), and minecarts only
enderchest.<slot_number>
0–26 players only
hotbar.<slot_number>
0–8
inventory.<slot_number>
0–26
horse.saddle
horses, donkeys, and mules; <item> must be a saddle or air to remove
horse.chest donkeys/mules and llamas; <item> must be a chest or air to remove
horse.armor
horses; <item> must be a type of horse armor or air to remove
llamas; <item> must be a type of carpet or air to remove
horse.<slot_number>
0–2 llamas with chests
0–14 donkeys/mules with chests
villager.<slot_number>
0–7 villagers and piglins only

<modifier>: resource_location

Specifies the item modifier to apply on the chosen item.
Must be a resource location.

<item>: item_stack

Specifies the item to be placed in the block or entity's inventory slot.
It must be in form of item_id{data_tags}(accepts item and block tags), in which data tags can be omitted when they are not needed.

<count>: integer

Specifies the number of items to be placed in the block or entity's inventory slot.
Must be a 32-bit integer number. And it must be between 1 and 64 (inclusive).

<sourcePos>: block_pos

Specifies the position of the block to copy items from.
It must be a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation.

<sourceTarget>: entity

Specifies an entity to copy items from.
Must be a player name, a target selector or a UUID.

<sourceSlot>: item_slot

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[]

CommandTriggerJava Edition
anythe arguments are not specified correctly Unparseable
<modifier> doesn't exist Failed
/item modify block ...
/item replace block ...
<pos> is unloaded or out of the world
the block at the <pos> is not a container
the block at the <pos> does not have the specified slot
/item modify entity ...
/item replace entity ...
<targets> fails to resolve to one or more entities (named player must be online)
All selected entities meet one or more of the following conditions:
  • It doesn't have the specified slot (for example, zombies have no horse.armor)
  • Specified item cannot be placed into the specified slot of its (for example, to place a stone into armor.chest of a player)
/... with <item> <count><count> exceeds the stack limit of the specified item
/... from block ...<sourcePos> is unloaded or out of the world
the block at <sourcePos> is not a container
the block at <sourcePos> does not have the specified slot
/... from entity ...<sourceTarget> fails to resolve to a single entity (named player must be online)
the <sourceTarget> doesn't have the specified slot (for example, zombies have no horse.armor)
anyOn successManipulate items in the specified slot.

Output[]

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
anyJava EditionOn fail000
/item (modify|replace) block ...On success111
/item (modify|replace) entity ...On success11the number of entities whose items are successfully replaced

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

History[]

Java Edition
1.1720w46aAdded /item, replacing /replaceitem.
21w19aSyntax of /item has been changed.

See also[]

  • /data — can also replace items in a container's or mob's inventory, or modify the drop chances of armor and weapons
  • /give — give items to players without specifying specific inventory slots or overwriting other items
  • /replaceitem — The Bedrock Edition equivalent
Advertisement