Manipulate items in the inventories of blocks (chest, furnaces, etc.) or entities (players or mobs).
... block <pos> ...or
... entity <targets> ...
... <slot> ...
... copy block <pos> <slot> [<modifier>]
... copy entity <targets> <slot> [<modifier>]
... modify <modifier>
... replace <item> [<count>]
- 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.
- 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
- 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 stands, mobs, and players only (though not all mobs will show or make use of the items)
0–53 players, item frames (slot 0), and minecarts only
0–26 players only
horses, donkeys, and mules;
<item>must be a saddle or air to remove
donkeys/mules and llamas;
<item>must be a chest or air to remove
<item>must be a type of horse armor or air to remove
<item>must be a type of carpet or air to remove
0–2 llamas with chests 0–14 donkeys/mules with chests
0–7 villagers and piglins only
- 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 item modifier to apply on the chosen item.
|any||the arguments are not specified correctly||Unparseable|
|if the specified block is not a container||Failed|
|if the specified block does not have the specified slot|
|if none of the targets have the specified slot (for example, zombies don't have |
|if specified item cannot be place into the specified slot of any targeted entity(for example, place a stone into armor.chest of a player)|
|any||On success||Replaces the items in the specified slot with the specified items (previous items in that slot are lost).|
|any||Java Edition||On fail||0||0||0|
|On success||1||1||the number of entities whose items are successfully replaced|
- To replace the items in the bottom-right slot of a single chest two block above with four spruce saplings:
item block ~ ~2 ~ container.26 replace minecraft:spruce_sapling 4
- To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
item entity @p hotbar.8 replace minecraft:spruce_sapling 4
- To replace the item in the offhand of the selected player with the item in their main hand:
item entity @s weapon.offhand copy entity @s weapon.mainhand
|Upcoming Java Edition|
/blockdata— can also replace items in a container
/entitydata— can also replace items in a 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