Manipulates items in the inventories of blocks (chests, hoppers, etc.) or entities (players, mobs). Replaces the removed /replaceitem command with expanded functionality including item modifiers.
/item replace block <pos> <slot> with <item> [<count>] /item replace entity <targets> <slot> with <item> [<count>] /item replace block <pos> <slot> from block <source pos> <source slot> [<modifier>] /item replace entity <targets> <slot> from entity <source> <source slot> [<modifier>] /item modify block <pos> <slot> <modifier> /item modify entity <targets> <slot> <modifier>
| Name | Required | Description |
|---|---|---|
| pos | Yes | Coordinates of the target block entity. |
| targets | Yes | The target entity/entities. |
| slot | Yes | The inventory slot (e.g., container.0, weapon.mainhand, armor.head). |
| item | Yes (replace with) | The item identifier to place in the slot. |
| count | No | Number of items (defaults to 1). |
| modifier | No / Yes (modify) | An item modifier defined in a data pack that transforms the item. |
| source pos / source | Yes (replace from) | The block or entity to copy an item from. |
| source slot | Yes (replace from) | The slot to copy from. |
/item replace entity @p weapon.mainhand with minecraft:diamond_sword /item replace block ~ ~-1 ~ container.0 with minecraft:redstone 64 /item replace entity @p armor.head from entity @e[type=zombie,limit=1] armor.head /item modify entity @p weapon.mainhand my_pack:enchant_sharpness
/replaceitem in Java Edition 1.17 (snapshot 20w46a).modify subcommand applies item modifiers from data packs, enabling powerful transformations like adding enchantments, lore, or other components.from subcommand copies items between inventories, optionally applying a modifier during the copy.armor.head, armor.chest, armor.legs, armor.feet, weapon.mainhand, weapon.offhand, container.0–container.53, and more.