Editing
MinecraftCommands
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== replaceitem === {{/infobox |replaceitem |op |1.8|14w26a }} Replaces items in the inventories of blocks (chest, furnaces, etc.) or entities (players or mobs) with the given item(s). ;Syntax : <code>replaceitem block <''x''> <''y''> <''z''> <''slot''> <''item''> [''amount''] [''data''] [''dataTag'']</code> : <code>replaceitem entity <''selector''> <''slot''> <''item''> [''amount''] [''data''] [''dataTag'']</code> ;Arguments : ''x y z'' (<code>block</code> mode only) :: Specifies the position of the block to be modified. May use [[#Tilde notation|tilde notation]] to specify a position relative to the command's execution. : ''selector'' (<code>entity</code> mode only) :: Specifies one or more entities to modify. Must be a player name or [[#Target selectors|target selector]]. : ''slot'' :: Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified. :: For blocks, must be <code>slot.container.''slot_number''</code> where ''slot_number'' is replaced with a number specifying the slot. ::* [[Chest]]s, [[dispenser]]s, [[dropper]]s, [[hopper]]s, and [[trapped chest]]s 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, and its top slot is 3. ::* A [[furnace]]'s slots are numbered 0 for the input slot, 1 for the fuel slot, and 2 for the output slot. ::Other blocks which hold items but don't have inventory GUIs ([[flower pot]]s and [[jukebox]]es) can only be changed with {{cmd|blockdata}}. :: For entities, must be one of the following, where ''slot_number'' is replaced with a number specifying the slot: :::{| class="wikitable" data-description="Slot information" !Slot !Slot Numbers !Restrictions |- |<code>slot.armor.chest</code> | |rowspan=4|[[armor stand]]s, [[mob]]s, and [[player]]s only (though not all mobs will show or make use of the items) |- |<code>slot.armor.feet</code> | |- |<code>slot.armor.head</code> | |- |<code>slot.armor.legs</code> | |- |<code>slot.weapon.mainhand</code> | |rowspan=2|works on players, [[armor stand]]s and [[mob]]s (though not all mobs will show or make use of the items). |- |<code>slot.weapon.offhand</code> | |- |<code>slot.enderchest.''slot_number''</code> |style="text-align: center;"|0 to 26 |rowspan=3|[[player]]s only |- |<code>slot.hotbar.''slot_number''</code> |style="text-align: center;"|0 to 8 |- |<code>slot.inventory.''slot_number''</code> |style="text-align: center;"|0 to 26 |- |<code>slot.horse.saddle</code> | |[[horse]]s, donkeys, and mules only; ''item'' must be a [[saddle]] |- |<code>slot.horse.armor</code> | |[[horse]]s only; ''item'' must be a type of [[horse armor]] |- |<code>slot.horse.chest.''slot_number''</code> |style="text-align: center;"|2 to 16 |donkeys and mules with chests only |- |<code>slot.villager.''slot_number''</code> |style="text-align: center;"|0 to 7 |[[villager]]s only |} :: The inventory of an [[item frame]] can only be changed with {{cmd|entitydata}}. : ''item'' :: Specifies the item to be placed in the block or entity's inventory slot. Must be an [[Data values#Item IDs|item id]], or a [[Data values#Block IDs|block id]] for which an item exists (for example, <code>minecraft:golden_sword</code>). : ''amount'' (optional) :: Specifies the number of items to be placed in the block or entity's inventory slot. Must be between 1 and 64 (inclusive), even for items with a smaller stack size. : ''data'' (optional) :: Specifies the item data for the item(s) to be placed in the block or entity's inventory slot. Must be an integer between -2,147,483,648 and 2,147,483,647 (inclusive, without the commas), but values which are invalid for the specified item id will default to 0. If not specified, defaults to 0. : ''dataTag'' (optional) :: Specifies the [[#Data tag|data tag]] for the item(s) to be placed in the block or entity's inventory slot. Must be a compound [[NBT tag]] (for example, <code>{display:{Name:Fred}}</code>). ;Result : Fails if the arguments are not specified correctly, if the specified block is not a container, if ''selector'' fails to resolve to one or more entities (named players must be online), or if none of the targeted entities have the specified slot (for example, zombies don't have <code>slot.horse.armor</code>). : On success, replaces the items in the specified slot with the specified items (previous items in that slot are lost) wherever possible. ;Examples : To replace the items in the bottom-right slot of a single chest one block above with four spruce saplings: :: <code>replaceitem block ~ ~1 ~ slot.container.26 minecraft:sapling 4 1</code> : To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings: :: <code>replaceitem entity @p slot.hotbar.8 minecraft:sapling 4 1</code> ;See also : {{cmd|blockdata}} β can also replace items in a container : {{cmd|entitydata}} β can also replace items in a mob's inventory, or modify the drop chances of armor and weapons : {{cmd|give}} β give items to players without specifying specific inventory slots or overwriting other items <!-- please retain double newline above for section differentiation -->
Summary:
Please note that all contributions to Hegemon Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Hegemon Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information