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
SyncBot (talk | contribs)
Sync: updated from Minecraft
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
Line 15: Line 15:
: <code>'''item replace''' (block <pos>|entity <targets>) <slot> '''from''' (block <sourcePos>|entity <sourceTarget>) <sourceSlot> [<modifier>]</code>
: <code>'''item replace''' (block <pos>|entity <targets>) <slot> '''from''' (block <sourcePos>|entity <sourceTarget>) <sourceSlot> [<modifier>]</code>
:: Copies the source items to the target slot and optionally modifies it with the <code>modifier</code>.
:: Copies the source items to the target slot and optionally modifies it with the <code>modifier</code>.
: <code>'''item override''' (block <pos>|entity <targets>) <slot> '''with''' <item> [<count>]</code>
: <code>'''item override''' (block <pos>|entity <targets>) <slots> '''with''' <item> [<count>]</code>
: <code>'''item override''' (block <pos>|entity <targets>) <slot> '''from''' (block <sourcePos>|entity <sourceTarget>) <sourceSlot> [<modifier>]</code>
: <code>'''item override''' (block <pos>|entity <targets>) <slots> '''from''' (block <sourcePos>|entity <sourceTarget>) <sourceSlots> [<modifier>]</code>
:: Appears to have same functionality as {{cd|'''item replace'''}} equivalent.{{info needed|However, there likely is a difference. Can someone find it?}}{{upcoming|je 26.3}}
:: Similar to {{cd|'''item replace'''}}, but can fill items across multiple slots. When there are more target slots than source slots, the extra target slots are cleared. See {{slink||Arguments}} and [[Minecraft:Slot]] for more details.{{upcoming|je 26.3}}<code>'''item fill''' (block <pos>|entity <targets>) <slots> '''with''' <item> [<count>]</code>
: <code>'''item fill''' (block <pos>|entity <targets>) <slots> '''with''' <item> [<count>]</code>
: <code>'''item fill''' (block <pos>|entity <targets>) <slots> '''from''' (block <sourcePos>|entity <sourceTarget>) <sourceSlots> [<modifier>]</code>
: <code>'''item fill''' (block <pos>|entity <targets>) <slots> '''from''' (block <sourcePos>|entity <sourceTarget>) <sourceSlots> [<modifier>]</code>
:: Similar to {{cd|'''item replace'''}}, but can fill items across multiple slots. See {{slink||Arguments}} and [[Minecraft:Slot]] for more details.
:: Similar to {{cd|'''item override'''}}, but instead of clearing extra target slots, items from the source slots are repeated to fill all target slots.{{upcoming|je 26.3}}


'''Syntax displayed in various ways'''
'''Syntax displayed in various ways'''
Line 31: Line 30:
** <code>... '''modify''' <''TARGET''> <slot> <modifier></code>
** <code>... '''modify''' <''TARGET''> <slot> <modifier></code>
** <code>... '''replace''' <''TARGET''> <slot></code>
** <code>... '''replace''' <''TARGET''> <slot></code>
** <code>... '''override''' <''TARGET''> <slots></code>
*** <code>... '''with''' <item> [<count>]</code>
*** <code>... '''with''' <item> [<count>]</code>
*** <code>... '''from''' <''SOURCE''> <sourceSlot> [<modifier>]</code>
*** <code>... '''from''' <''SOURCE''> <sourceSlot> [<modifier>]</code>
** <code>... '''override''' <''TARGET''> <slots></code>
** <code>... '''fill''' <''TARGET''> <slots></code>
** <code>... '''fill''' <''TARGET''> <slots></code>
*** <code>... '''with''' <item> [<count>]</code>
*** <code>... '''with''' <item> [<count>]</code>
Line 47: Line 46:
|-
|-
|
|
: <code>item (modify (block <pos>&vert;entity <targets>) <slot> <modifier>&vert;(replace&vert;override) (block <pos>&vert;entity <targets>) <slot> (with <item> [<count>]&vert;from (block <sourcePos>&vert;entity <sourceTarget>) <sourceSlot> [<modifier>])&vert;fill (block <pos>&vert;entity <targets>) <slots> (with <item> [<count>]&vert;from (block <sourcePos>&vert;entity <sourceTarget>) <sourceSlots> [<modifier>]))</code>
: <code>item (modify (block <pos>&vert;entity <targets>) <slot> <modifier>&vert;replace (block <pos>&vert;entity <targets>) <slot> (with <item> [<count>]&vert;from (block <sourcePos>&vert;entity <sourceTarget>) <sourceSlot> [<modifier>])&vert;(override|fill) (block <pos>&vert;entity <targets>) <slots> (with <item> [<count>]&vert;from (block <sourcePos>&vert;entity <sourceTarget>) <sourceSlots> [<modifier>]))</code>
|}
|}
:{| class="collapsible collapsed collapse-button-none" data-description="maximised_tree"
:{| class="collapsible collapsed collapse-button-none" data-description="maximised_tree"
Line 63: Line 62:
: <code>item replace entity <targets> <slot> from entity <sourceTarget> <sourceSlot> [<modifier>]</code>
: <code>item replace entity <targets> <slot> from entity <sourceTarget> <sourceSlot> [<modifier>]</code>
: <code>item override block <pos> <slot> with <item> [<count>]</code>
: <code>item override block <pos> <slot> with <item> [<count>]</code>
: <code>item override block <pos> <slot> from block <sourcePos> <sourceSlot> [<modifier>]</code>
: <code>item override block <pos> <slot> from block <sourcePos> <sourceSlots> [<modifier>]</code>
: <code>item override block <pos> <slot> from entity <sourceTarget> <sourceSlot> [<modifier>]</code>
: <code>item override block <pos> <slot> from entity <sourceTarget> <sourceSlots> [<modifier>]</code>
: <code>item override entity <targets> <slot> with <item> [<count>]</code>
: <code>item override entity <targets> <slot> with <item> [<count>]</code>
: <code>item override entity <targets> <slot> from block <sourcePos> <sourceSlot> [<modifier>]</code>
: <code>item override entity <targets> <slot> from block <sourcePos> <sourceSlots> [<modifier>]</code>
: <code>item override entity <targets> <slot> from entity <sourceTarget> <sourceSlot> [<modifier>]</code>
: <code>item override entity <targets> <slot> from entity <sourceTarget> <sourceSlots> [<modifier>]</code>
: <code>item fill block <pos> <slots> with <item> [<count>]</code>
: <code>item fill block <pos> <slots> with <item> [<count>]</code>
: <code>item fill block <pos> <slots> from block <sourcePos> <sourceSlots> [<modifier>]</code>
: <code>item fill block <pos> <slots> from block <sourcePos> <sourceSlots> [<modifier>]</code>
Line 111: Line 110:
{{argument|sourceTarget|entity}}
{{argument|sourceTarget|entity}}
: Specifies an entity to copy items from.
: Specifies an entity to copy items from.
: {{arg desc|je=entity|amount=single}}
: {{arg desc|je=entity|amount=single|type=entities}}{{Until|je 26.3}}


{{argument|sourceSlot|item_slot}}
{{argument|sourceSlot|item_slot}}

Latest revision as of 11:04, 26 July 2026

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

Syntax

item modify (block <pos>|entity <targets>) <slot> <modifier>
Modifies the items in the specified slot with the specified Minecraft: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.
item override (block <pos>|entity <targets>) <slots> with <item> [<count>]
item override (block <pos>|entity <targets>) <slots> from (block <sourcePos>|entity <sourceTarget>) <sourceSlots> [<modifier>]
Similar to Template:Cd, but can fill items across multiple slots. When there are more target slots than source slots, the extra target slots are cleared. See Template:Slink and Minecraft:Slot for more details.Template:Upcomingitem fill (block <pos>|entity <targets>) <slots> with <item> [<count>]
item fill (block <pos>|entity <targets>) <slots> from (block <sourcePos>|entity <sourceTarget>) <sourceSlots> [<modifier>]
Similar to Template:Cd, but instead of clearing extra target slots, items from the source slots are repeated to fill all target slots.Template:Upcoming

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

Similar to Template:Argument, but can contain multiple slots.
Template:Arg desc

Template:Argument

Specifies the Minecraft: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 descTemplate:Until

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

Template:Argument

Similar to Template:Argument, but can contain multiple slots.
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

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