Minecraft:Commands/replaceitem: Difference between revisions
More actions
imported>LauraFii →History: split |
Remove broken links to missing pages |
||
| Line 1: | Line 1: | ||
{{For||Item (disambiguation)}} | {{For||Item (disambiguation)}} | ||
{{exclusive|Bedrock|Education}} | {{exclusive|Bedrock|Education}} | ||
{{outdated|edition=java|This command was superseded by the {{cmd|item}} command in | {{outdated|edition=java|This command was superseded by the {{cmd|item}} command in Java Edition 1.17.}} | ||
{{Infobox command | {{Infobox command | ||
|name=replaceitem | |name=replaceitem | ||
| Line 7: | Line 7: | ||
|cheat=y | |cheat=y | ||
}} | }} | ||
Replaces the [[Minecraft:item]]s in a specified slot of either a [[Minecraft:block|block']]s ([[Minecraft:chest]], [[Minecraft:furnace]]s, etc.) or | Replaces the [[Minecraft:item]]s in a specified slot of either a [[Minecraft:block|block']]s ([[Minecraft:chest]], [[Minecraft:furnace]]s, etc.) or entity's (players or mobs) [[Minecraft:inventory]], with a specified item. | ||
== Syntax == | == Syntax == | ||
| Line 83: | Line 83: | ||
|{{HistoryLine|java}} | |{{HistoryLine|java}} | ||
|{{HistoryLine||1.8|dev=14w26a|Added {{cmd|replaceitem|link=none}}.}} | |{{HistoryLine||1.8|dev=14w26a|Added {{cmd|replaceitem|link=none}}.}} | ||
|{{HistoryLine||1.14|dev=18w43a|{{cmd|replaceitem|link=none}} can now be used on | |{{HistoryLine||1.14|dev=18w43a|{{cmd|replaceitem|link=none}} can now be used on item frames.}} | ||
|{{HistoryLine||1.17|dev=20w46a|Removed {{cmd|replaceitem|link=none}}. Replaced with {{cmd|item replace}}.}} | |{{HistoryLine||1.17|dev=20w46a|Removed {{cmd|replaceitem|link=none}}. Replaced with {{cmd|item replace}}.}} | ||
}} | }} | ||
| Line 108: | Line 108: | ||
{{Navbox commands}} | {{Navbox commands}} | ||
de:Befehl/replaceitem | |||
ja:コマンド/replaceitem | |||
pt:Comandos/replaceitem | |||
ru:Команды консоли/replaceitem | |||
uk:Команди консолі/replaceitem | |||
zh:命令/replaceitem | |||
Latest revision as of 15:45, 9 April 2026
Template:For Template:Exclusive Template:Outdated Template:Infobox command Replaces the Minecraft:items in a specified slot of either a block's (Minecraft:chest, Minecraft:furnaces, etc.) or entity's (players or mobs) Minecraft:inventory, with a specified item.
Syntax
replaceitem block <position: x y z> slot.container <slotId: int> <itemName: Item> [amount: int] [data: int] [components: json]replaceitem entity <target: target> <slotType: EntityEquipmentSlot> <slotId: int> <itemName: Item> [amount: int] [data: int] [components: json]replaceitem block <position: x y z> slot.container <slotId: int> <oldItemHandling: ReplaceMode> <itemName: Item> [amount: int] [data: int] [components: json]replaceitem entity <target: target> <slotType: EntityEquipmentSlot> <slotId: int> <oldItemHandling: ReplaceMode> <itemName: Item> [amount: int] [data: int] [components: json]
Arguments
- Specifies the position of the block to be modified.
- Template:Arg desc
- Specifies one or more entities to modify.
- Template:Arg desc
Template:Argument, slot.container and Template:Argument
- Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified. See Minecraft:Slot for details.
slotId: intTemplate:Arg desc And it must be between -2147483648 and 2147483647 (inclusive).
- 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.
- Template:Arg desc And it should 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 defaults to 0. If not specified, defaults to 0.
- Template:Arg desc It must be between -2147483648 and 2147483647 (inclusive).
- Specifies the Minecraft:item components. Like data tags but supports only
minecraft:can_place_on,minecraft:can_destroy,minecraft:item_lock, andminecraft:keep_on_deathfunctions (see Minecraft:Commands/give#Examples) - Template:Arg desc
- Must be one of:
destroy- Directly replaces items ignoring the original items in the specified slot.keep- Does not replace items if an item occupies that slot.
Result
Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table
Output
Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table
Examples
- To replace the items in the bottom-right slot of a single chest two block above with four spruce saplings:
replaceitem block ~ ~2 ~ slot.container 26 sapling 4 1
- To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
replaceitem entity @p slot.hotbar 8 sapling 4 1
History
Java Edition
Bedrock Edition
See also
- Template:Cmd — the Template:El equivalent
- Template:Cmd — give items to players without specifying specific inventory slots or overwriting other items
- Template:Cmd (outdated) — can replace a slot of a mob's inventory
External links
de:Befehl/replaceitem ja:コマンド/replaceitem pt:Comandos/replaceitem ru:Команды консоли/replaceitem uk:Команди консолі/replaceitem zh:命令/replaceitem