Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/replaceitem: Difference between revisions

From SAS Gaming Wiki
imported>LauraFii
History: split
 
SyncBot (talk | contribs)
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 [[Minecraft:Java Edition 1.17]].}}
{{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 [[Minecraft:Entity|entity's]] ([[Minecraft:players]] or [[Minecraft:mobs]]) [[Minecraft:inventory]], with a specified item.
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 [[Minecraft:item frame]]s.}}
|{{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}}


[[Minecraft:de:Befehl/replaceitem]]
de:Befehl/replaceitem
[[Minecraft:ja:コマンド/replaceitem]]
ja:コマンド/replaceitem
[[Minecraft:pt:Comandos/replaceitem]]
pt:Comandos/replaceitem
[[Minecraft:ru:Команды консоли/replaceitem]]
ru:Команды консоли/replaceitem
[[Minecraft:uk:Команди консолі/replaceitem]]
uk:Команди консолі/replaceitem
[[Minecraft:zh:命令/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

Template:Argument

Specifies the position of the block to be modified.
Template:Arg desc

Template:Argument

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: int Template:Arg desc And it must be between -2147483648 and 2147483647 (inclusive).

Template:Argument

Specifies the item to be placed in the block or entity's inventory slot.

Template:Argument

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).

Template:Argument

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).

Template:Argument

Specifies the Minecraft:item components. Like data tags but supports only minecraft:can_place_on, minecraft:can_destroy, minecraft:item_lock, and minecraft:keep_on_death functions (see Minecraft:Commands/give#Examples)
Template:Arg desc

Template:Argument

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

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

See also

External links

Navigation

Template:Navbox commands

de:Befehl/replaceitem ja:コマンド/replaceitem pt:Comandos/replaceitem ru:Команды консоли/replaceitem uk:Команди консолі/replaceitem zh:命令/replaceitem