
Command
/item
Puts items into chosen inventory slots of entities or container blocks, copies items between slots, or changes the items already there.
| /item (fill|override|replace) (block <target>|entity <target>) <slots> from (block <source>|entity <source>) <sourceSlots> [<modifier>] |
| /item (fill|override|replace) (block <target>|entity <target>) <slots> with <item> [<count>] |
| /item modify (block <target>|entity <target>) <slots> <modifier> |
| Argument | Kind of value | What to type |
|---|---|---|
| <target> | Block position | Where the items go: a block position after block, or one or more entities after entity. |
| <slots> | Item slots | The slots to change: a slot name such as weapon.mainhand, a group such as hotbar.*, or a slot source from a data pack or written inline. |
| <source> | Block position | For from: the block position or the entities the items are copied from. |
| <sourceSlots> | Item slots | For from: the slots the items are copied from, written like slots. |
| <modifier> | Item modifier | The id of an item modifier from a data pack, or an item modifier written inline. |
| <item> | Item | For with: the item id, optionally followed by components in square brackets. |
| <count> | Whole number | For with: the size of the stack, from 1 to 99. Defaults to 1. |
| Permission level | 2: operators, worlds with cheats on, command blocks and functions |
| Works in | Operators on multiplayer servers, singleplayer worlds with cheats enabled, and command blocks and functions. |
| Result | Reports "Replaced ... slot(s)" or "Modified ... slot(s)" with the entity or block position. The number /execute store saves is the number of slots that were changed. |
| replace | Puts the given items into the chosen slots one after another and stops when the items run out. With a single item and several slots, only the first slot of each target receives it. |
| fill | Puts the given items into every chosen slot, starting again from the first item when the items run out. |
| override | Puts the given items into the chosen slots one after another and empties the chosen slots that are left over. |
| modify | Applies an item modifier to the items in the chosen slots. Empty slots are skipped. |
| with | Uses a new item written in the command, with an optional count from 1 to 99. |
| from | Copies the items from slots of another block or of entities. An optional item modifier is applied to the copies before they are placed. The source keeps its items. |
| Slot names | Single slots: contents, container.0 to container.53, hotbar.0 to hotbar.8, inventory.0 to inventory.26, enderchest.0 to enderchest.26, mob.inventory.0 to mob.inventory.7, horse.0 to horse.14, weapon, weapon.mainhand, weapon.offhand, armor.head, armor.chest, armor.legs, armor.feet, armor.body, saddle, horse.chest, player.cursor and player.crafting.0 to player.crafting.3. Whole groups: container.*, hotbar.*, inventory.*, enderchest.*, mob.inventory.*, horse.*, weapon.*, armor.* and player.crafting.*. |
| Blocks must be containers | A block target or source must be a block with an inventory, such as a Chest. Otherwise the command fails with "is not a container". |
| Missing slots | Fails with "The target does not have slot ..." if no target has the chosen slots, and with "The source does not have slot ..." if the source has none of them. |
| Nothing changed | Fails with "No targets accepted items into specified slots" if no slot was changed. |
/item replace entity @s weapon.mainhand with minecraft:diamond_swordPuts a Diamond Sword in your main hand, replacing what you hold.
/item replace block ~ ~-1 ~ container.0 with minecraft:diamond 16Puts 16 Diamonds in the first slot of the container below you.
/item fill entity @s hotbar.* with minecraft:torch 64Fills every slot of your hotbar with a stack of 64 Torches.
/item replace entity @s armor.head from entity @s weapon.mainhandPuts a copy of the item you are holding on your head.
/item override block ~ ~-1 ~ container.* from entity @s hotbar.*Copies your hotbar into the container below you and empties its remaining slots.



