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/item: Difference between revisions

From SAS Gaming Wiki
imported>RedX
No edit summary
 
SyncBot (talk | contribs)
Remove broken links to missing pages
Line 5: Line 5:
|oplevel=2
|oplevel=2
}}
}}
Manipulate or copy [[Minecraft:item]]s in the [[Minecraft:inventories]] of [[Minecraft:block]]s ([[Minecraft:chest]]s, [[Minecraft:furnace]]s, etc.) or [[Minecraft:entities]] ([[Minecraft:player]]s or [[Minecraft:mob]]s).
Manipulate or copy [[Minecraft:item]]s in the inventories of [[Minecraft:block]]s ([[Minecraft:chest]]s, [[Minecraft:furnace]]s, etc.) or entities (players or [[Minecraft:mob]]s).


== Syntax ==
== Syntax ==
: <code>'''item modify''' (block <pos>|entity <targets>) <slot> <modifier></code>
: <code>'''item modify''' (block <pos>|entity <targets>) <slot> <modifier></code>
:: Modifies the items in the specified slot with the specified [[Minecraft:item modifier]].
:: Modifies the items in the specified slot with the specified item modifier.
: <code>'''item replace''' (block <pos>|entity <targets>) <slot> '''with''' <item> [<count>]</code>
: <code>'''item replace''' (block <pos>|entity <targets>) <slot> '''with''' <item> [<count>]</code>
:: Replaces the items in the specified slot with the specified items.
:: Replaces the items in the specified slot with the specified items.
Line 67: Line 67:


{{argument|modifier|loot_modifier}}
{{argument|modifier|loot_modifier}}
: Specifies the [[Minecraft:item modifier]] to apply on the chosen item.
: Specifies the item modifier to apply on the chosen item.
: {{Arg desc|je=loot_modifier}}
: {{Arg desc|je=loot_modifier}}


Line 144: Line 144:
{{HistoryTable
{{HistoryTable
|{{HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||November 8, 2017|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-17w45a|A command called {{cmd|modifyitem|link=none}} was mentioned in snapshot's [[Minecraft:Java Edition 17w45a]] update log at [[Minecraft:minecraft.net]]. At first it was planned to replace {{cmd|enchant}}.}}
|{{HistoryLine||November 8, 2017|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-17w45a|A command called {{cmd|modifyitem|link=none}} was mentioned in snapshot's Java Edition 17w45a update log at minecraft.net. At first it was planned to replace {{cmd|enchant}}.}}
|{{HistoryLine||February 9, 2018|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-18w06a|In [[Minecraft:Java Edition 18w06a]]'s update logs, [[Minecraft:Dinnerbone]] states that the team has shelved the {{cmd|modifyitem|link=none}} idea, but that it may be considered the future.}}
|{{HistoryLine||February 9, 2018|link=https://www.minecraft.net/en-us/article/minecraft-snapshot-18w06a|In Java Edition 18w06a's update logs, Dinnerbone states that the team has shelved the {{cmd|modifyitem|link=none}} idea, but that it may be considered the future.}}
|{{HistoryLine||1.17|dev=20w46a|Added {{cmd|item|link=none}}, replacing {{cmd|replaceitem}} and reusing the idea of {{cmd|modifyitem|link=none}} through one of its arguments, <code>modify</code>, which in fact contains a similar functionality to {{cmd|enchant|link=none}}, as they use [[Minecraft:item modifier]]s capable of changing the specified item's enchantments.}}
|{{HistoryLine||1.17|dev=20w46a|Added {{cmd|item|link=none}}, replacing {{cmd|replaceitem}} and reusing the idea of {{cmd|modifyitem|link=none}} through one of its arguments, <code>modify</code>, which in fact contains a similar functionality to {{cmd|enchant|link=none}}, as they use item modifiers capable of changing the specified item's enchantments.}}
|{{HistoryLine|||dev=21w19a|Syntax of {{cmd|item|link=none}} has been changed.}}
|{{HistoryLine|||dev=21w19a|Syntax of {{cmd|item|link=none}} has been changed.}}
|{{HistoryLine||1.19|dev=Pre-release 1|Replacing the off-hand slot using {{cmd|item|link=none}} no longer produces a [[Minecraft:vibration]].<ref>{{bug|MC-250022}}</ref>}}
|{{HistoryLine||1.19|dev=Pre-release 1|Replacing the off-hand slot using {{cmd|item|link=none}} no longer produces a [[Minecraft:vibration]].<ref>{{bug|MC-250022}}</ref>}}
|{{HistoryLine||1.20.2|dev=23w31a|Can now replace items in [[Minecraft:jukebox]]es.
|{{HistoryLine||1.20.2|dev=23w31a|Can now replace items in [[Minecraft:jukebox]]es.
|Can now remove items in [[Minecraft:chiseled bookshelves]].}}
|Can now remove items in chiseled bookshelves.}}
}}
}}


Line 161: Line 161:
{{Navbox commands}}
{{Navbox commands}}


[[Minecraft:de:Befehl/item]]
de:Befehl/item
[[Minecraft:es:Comandos/item]]
es:Comandos/item
[[Minecraft:ja:コマンド/item]]
ja:コマンド/item
[[Minecraft:pt:Comandos/item]]
pt:Comandos/item
[[Minecraft:ru:Команды консоли/item]]
ru:Команды консоли/item
[[Minecraft:zh:命令/item]]
zh:命令/item

Revision as of 15:44, 9 April 2026

Template:Exclusive Template:Infobox command Manipulate or copy Minecraft:items in the inventories of Minecraft:blocks (Minecraft:chests, Minecraft:furnaces, etc.) or entities (players or Minecraft:mobs).

Syntax

item modify (block <pos>|entity <targets>) <slot> <modifier>
Modifies the items in the specified slot with the specified item modifier.
item replace (block <pos>|entity <targets>) <slot> with <item> [<count>]
Replaces the items in the specified slot with the specified items.
item replace (block <pos>|entity <targets>) <slot> from (block <sourcePos>|entity <sourceTarget>) <sourceSlot> [<modifier>]
Copies the source items to the target slot and optionally modifies it with the modifier.

Syntax displayed in various ways

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

Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
Template:Arg desc

Template:Argument

Specifies the item modifier to apply on the chosen item.
Template:Arg desc

Template:Argument

Specifies the item to be placed in the block or entity's inventory slot.
Template:Arg desc

Template:Argument

Specifies the number of items to be placed in the block or entity's inventory slot.
Template:Arg desc

Template:Argument

Specifies the position of the block to copy items from.
Template:Arg desc

Template:Argument

Specifies an entity to copy items from.
Template:Arg desc

Template:Argument

Specifies the inventory slot to copy the items from. Valid values depend on whether the source is block or an entity.
Template:Arg desc

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 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:
    • /item replace block ~ ~2 ~ container.26 with minecraft:spruce_sapling 4
  • To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
    • /item replace entity @p hotbar.8 with minecraft:spruce_sapling 4
  • To replace the item in the offhand of the selected player with the item in their main hand:
    • /item replace entity @s weapon.offhand from entity @s weapon.mainhand
  • To put a brown Minecraft:banner on a player's head
    • /item replace entity @s armor.head with minecraft:brown_banner
  • To increase the count of the item in your main hand:
    • /item modify entity @s weapon.mainhand example:increase_count
    • file in a data pack: data/example/item_modifier/increase_count.json<syntaxhighlight lang="json">{
 "function": "minecraft:set_count",
 "count": 1,
 "add": true

}</syntaxhighlight>

  • To increase the count of the item in your main hand without external files:
    • item modify entity @s weapon.mainhand {"function":"minecraft:set_count","count":1,"add":true}
  • To put the item in your hand, on your head:
    • /item replace entity @s armor.head from entity @s weapon.mainhand

History

Template:HistoryTable

See also

  • Template:Cmd — can also replace items in a container's or mob's inventory, or modify the drop chances of armor and weapons
  • Template:Cmd — give items to players without specifying specific inventory slots or overwriting other items
  • Template:Cmd — The Template:El equivalent

Navigation

Template:Navbox commands

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