Commands/replaceitem

Replaces items in the inventories of blocks (chest, furnaces, etc.) or entities (players or mobs) with the given item(s).

Arguments

 * Specifies the position of the block to be modified.


 * Specifies one or more entities to modify.
 * List of entities with an inventory:
 * {|class='wikitable'
 * {|class='wikitable'

!Name !Entity type !Inventory slots !Main hand !Offhand !Hotbar slots !Horse armor slot !Saddle slot !Chest slots !Enderchest slots
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }
 * }

,  and
 * Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
 * And it must be between -2147483648 and 2147483647 (inclusive).


 * For blocks, must be   where  or  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.
 * For entities, must be one of the following, where slot number or slot id is replaced with a number specifying the slot:


 * {| class="wikitable" data-description="Slot information"

!Slot !Slot Numbers !Restrictions
 * any number
 * rowspan=6|mobs (including armor stands), and players only (though not all mobs will show or make use of the items)
 * any number
 * any number
 * any number
 * any numbe
 * any number
 * align="center"|0–8
 * players only
 * align="center"|0–the number of slots in inventory
 * entities with  component only
 * align="center"|0–26
 * players only
 * any number
 * horses, donkeys, and mules only;  must be a saddle
 * any number
 * horses only;  must be a type of horse armor
 * align="center"|0–the number of slots in chest
 * donkeys and mules with chests only
 * align="center"|-
 * unsupported
 * }
 * players only
 * align="center"|0–the number of slots in inventory
 * entities with  component only
 * align="center"|0–26
 * players only
 * any number
 * horses, donkeys, and mules only;  must be a saddle
 * any number
 * horses only;  must be a type of horse armor
 * align="center"|0–the number of slots in chest
 * donkeys and mules with chests only
 * align="center"|-
 * unsupported
 * }
 * any number
 * horses only;  must be a type of horse armor
 * align="center"|0–the number of slots in chest
 * donkeys and mules with chests only
 * align="center"|-
 * unsupported
 * }
 * align="center"|-
 * unsupported
 * }
 * unsupported
 * }


 * 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.
 * And it must be between 1 and 64 (inclusive).


 * Specifies the item data for the item(s) to be placed in the block or entity's inventory slot. Values which are invalid for the specified item id will default to 0. If not specified, defaults to 0.
 * It must be between -2147483648 and 2147483647 (inclusive).


 * Specifies the item components. Like data tags but supports only,  ,  , and   functions (see Commands/give)


 * Must be one of:
 * - Directly replaces items ignoring the original items in the specified slot.
 * - Does not replace items if an item occupies that slot.

Examples

 * To replace the items in the bottom-right slot of a single chest two block above with four spruce saplings:
 * To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
 * To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings: