Inventory Slot Id Minecraft Rating: 6,1/10 1802 reviews
Block

Component name:inventory_controller

  1. GetStackInSlot(side:number, slot:number):table Returns a table describing the item in the specified slot or nil. Deprecated for getting info about robot's own inventory, see getStackInInternalSlot. Side - must be a valid side. Slot - the slot to analyze. This does not check the inventory size and will consider slots outside the inventory bounds.
  2. I am, of course, playing the newest version of Minecraft. Thank you in advance for your help, ArthurPhoenix:3. Edit: Thanks to the people who have commented so far, I learned that replacing 'Inventory' with 'SelectedItem' tests for the item held by the player instead of executing the command if it is placed in any inventory slot.
  3. The inventory consists of 4 armor slots, 27 storage slots, and 9 hotkey slots (this group of slots is sometimes called the 'Hotbar' or 'quick-access bar'). Items in the hotkey slots can be selected during gameplay using the keyboard (keys 1-9) or mouse wheel, placed, or wielded with the mouse buttons on PC.

The slot number is calculated starting at 0, counting up through the window's unique slots, and then counting through the players inventory. For all windows, the slot in the upper-left corner of the player's inventory is slot n where n is the number of unique slots, and slot number -999 is always used for clicking outside the window. Set slot 0 of player's inventory to compass named '&a&lServer Selector &7&l(Right-Click)' #2 ShaneBee, Mar 2, 2017. Moderator Resource Staff Supporter.

This component is provided by the inventory controller upgrade.

With this API the robot can receive additional information about items or inventories and is able to put items into and take them from specific slots.

Sides required for most operations are specified in the Sides API. If no or an invalid side is provided functions will usually throw an error. To interact with the robot's own inventory you need to use the side back, which however makes it impossible to interact with inventories behind the robot. Robots cannot access their left or right sides. You can interact with external inventories in front of, above, or below the robot.

Callbacks:

  • getInventorySize(side: number): number or nil[, string]
    Returns the size of the inventory at the specified side.side - must be a valid side.
    Returns: the size of the inventory, or nil followed by a description why this function failed (usually no inventory).
  • getStackInSlot(side:number, slot:number):table
    Returns a table describing the item in the specified slot or nil. Deprecated for getting info about robot's own inventory, see getStackInInternalSlot.
    side - must be a valid side.
    slot - the slot to analyze. This does not check the inventory size and will consider slots outside the inventory bounds to be empty.
    Returns:nil if the slot was empty (or outside the inventory's bounds), a table otherwise with the following information about the item in that slot:
    • damage:number - the current damage value of the item.
    • maxDamage:number - the maximum damage this item can have before it breaks.
    • maxSize:number - the maximum stack size of this item.
    • id:number - the Minecraft id of the item. Note that this field is only included if insertIdsInConverters=true in the configs, and can vary between servers!
    • name:string - the untranslated item name, which is an internal Minecraft value like oc:item.FloppyDisk
    • hasTag:boolean - whether or not the item has an NBT tag associated with it.
  • getStackInInternalSlot(slot:number):table
    Gets Itemstack description of item in specified or selected slot (if no input provided) of robot inventory.
  • dropIntoSlot(side:number, slot:number[, count:number]):boolean[, string]
    Puts up to count items from the currently selected slot into the specified slot of the inventory at the specified side.
    side - a valid side.
    slot - the slot to drop the item into.
    count - how many items to transfer.
    Returns:true if at least one item was moved, false and a secondary result that describes the error otherwise.
    Note that the robot cannot drop items into it's own inventory, attempting to do so will cause this to throw an error. You need to use robot.transferTo from the Robot API to do so.
  • suckFromSlot(side:number, slot:number[, count:number]):boolean
    Takes up to count items from the specified slot of the inventory at the specified side and puts them into the currently selected slot.
    side - a valid side.
    slot - the slot to take the item from.
    count - how many items to transfer.
    Returns:true if at least one item was moved, false otherwise.
    If the currently selected slot is occupied, then the items will be stacked with similar items in the robot's inventory or moved to the next free slot if available. If no slot is available this operation will fail.
    Note that the robot cannot suck items from it's own inventory, attempting to do so will cause this to throw an error. You need to use robot.transferTo from the Robot API to do so.
  • equip():boolean
    Swaps the content of the robot's tool slot with the content of the currently selected inventory slot.
    Returns:true if the items were swapped, false otherwise. This operation usually succeeds.
    Note that you can put any kind of item into the robot's tool slot, not only tools, even items that the robot cannot use at all.
  • store(side:number, slot:number, dbAddress:string, dbSlot:number):boolean
    Stores the Itemstack description of the item from the specified slot in an inventory on the specified side, into a specified database slot with the specified address.
  • storeInternal(slot:number, dbAddress:string, dBslot:number):boolean
    Stores Itemstack description of item in specified robot inventory slot into specified database slot with the specified database address.
  • compareToDatabase(slot:number, dBaddress:string, dBslot:number):boolean
    Compare Itemstack description in specified slot with one in specified slot of a database with specified address. Returns true if items match.
  • compareStacks(side:number, slotA:number, slotB:number):boolean
    Checks to see if Itemstack descriptions in specified slotA and slotB of inventory on specified side match. Returns true if identical.
  • getSlotMaxStackSize(side:number, slot:number):number
    Gets maximum number of items in specified slot in inventory on the specified side.
  • getSlotStackSize(side:number, slot:number):number
    Gets number of items in specified slot in inventory on the specified side.

Example:

Print meta-info about the item in the position indicated by slot

snippet.lua
< Commands
This page contains information about features that have been removed in the latest development versions.
These features are present in the current version, but may be removed when the next update is released.
Restrictions
First introduced

Java Edition 1.8 (14w26a)
PE 1.0.5 (PE alpha 1.0.5.0)

Replaces items in the inventories of blocks (chest, furnaces, etc.) or entities (players or mobs) with the given item(s).

Inventory Slot Id Minecraft Servers

Syntax[edit]

  • Java Edition
replaceitem block <pos> <slot> <item> [<count>]
replaceitem entity <targets> <slot> <item> [<count>]
  • Bedrock Edition
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[edit]

JE: <pos>: block_pos
BE: position: x y z: CommandPosition

In Java Edition, it must be a block position composed of <x>, <y> and <z>, each of which must be an integer or tilde and caret notation.In Bedrock Edition, it must be a three-dimensional coordinates composed of <x>, <y> and <z>, each of which must be a floating-point number or tilde and caret notation.
Specifies the position of the block to be modified.

JE: <targets>: entity
BE: target: target: CommandSelector<Actor>

Must be a player name, a target selector or a UUID‌[Java Edition only].
Specifies one or more entities to modify.

JE: <slot>: item_slot
BE: slotType: EntityEquipmentSlot: EquipmentSlot, slot.container and <slotId: int>: int

Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
In Bedrock Edition, slotId: int must be a 32-bit integer number. And it must be between -2147483648 and 2147483647 (inclusive).
For blocks, must be container.<slot_number> (BE: slot.container <slotId: int>) where <slot_number> or <slotId: int> is replaced with a number specifying the slot.
  • Chests, dispensers, droppers, hoppers, and trapped chests 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, its top slot is 3 and the fuel slot is 4.
  • 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 pots and jukeboxes) can only be changed with /data.
For entities, must be one of the following, where slot number or slot id is replaced with a number specifying the slot:

Inventory Slot Id Minecraft

SlotSlot NumbersRestrictions
armor.chest(BE: slot.armor.chest <slotId: int>)any number‌[Bedrock Edition only]armor stands, mobs, and players only (though not all mobs will show or make use of the items)
armor.feet(BE: slot.armor.feet <slotId: int>)any number‌[Bedrock Edition only]
armor.head(BE: slot.armor.head <slotId: int>)any number‌[Bedrock Edition only]
armor.legs(BE: slot.armor.legs <slotId: int>)any number‌[Bedrock Edition only]
weapon.mainhand(BE: slot.weapon.mainhand <slotId: int>)any number‌[Bedrock Edition only]
weapon.offhand(BE: slot.weapon.offhand <slotId: int>)any number‌[Bedrock Edition only]
container.<slot_number>(BE: slot.container <slotId: int>)0–53players, item frames‌[Java Edition only] (slot 0), and minecarts only
enderchest.<slot_number>
(BE: slot.enderchest <slotId: int>)
0–26players only
hotbar.<slot_number>
(BE: slot.hotbar <slotId: int>)
0–8
inventory.<slot_number>
(BE: slot.inventory <slotId: int>)
0–26
horse.saddle
(BE: slot.saddle <slotId: int>)
any number‌[Bedrock Edition only]horses, donkeys, and mules only; <item> or itemName: Item must be a saddle
horse.chest[Java Edition only]donkeys, and mules only; <item> must be a chest
horse.armor
(BE: slot.armor <slotId: int>)
any number‌[Bedrock Edition only]horses and llamas only; <item> or itemName: Item must be a type of horse armor (if a horse) or a carpet (if a llama)
horse.<slot_number>
(BE: slot.chest <slotId: int>)
0–14donkeys and mules with chests only
villager.<slot_number>
(BE: slot.inventory <slotId: int>)
0–7villagers only
Slot

JE: <item>: item_stack
BE: itemName: Item: CommandItem

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

JE: <count>: integer
BE: amount: int: int

Must be a 32-bit integer number. In Java Edition, it must be between -2147483648 and 2147483647 (inclusive). And it must be between 1 and 64 (inclusive).
Specifies the number of items to be placed in the block or entity's inventory slot.

BE: data: int: int

Inventory Slot Id Minecraft Block

Must be a 32-bit integer number. It must be between -2147483648 and 2147483647 (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 will default to 0. If not specified, defaults to 0.

BE: components: json: Json::Value

Inventory Slot Id Minecraft 1.8

Must be a JSON Object.
Specifies the 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 Commands/give#Examples)

BE: oldItemHandling: ReplaceMode

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[edit]

Inventory Slot Id Minecraft Mod

CommandTriggerJava EditionBedrock Edition
anythe arguments are not specified correctly Unparseable Failed
<count> exceeds the stack limit of the specified item Failed Successful
/replaceitem block ...if the specified block is not a container Failed
if the specified block does not have the specified slot
/replaceitem entity ...if <targets> or target: target fails to resolve to one or more entities (named players must be online)
if none of the targets have the specified slot (for example, zombies don't have horse.armor)
if specified item cannot be place into the specified slot of any targeted entity(for example, place a stone into armor.chest of a player)
/replaceitem ... keepif an item occupies the specified slot in keep mode N/A
anyOn successReplaces the items in the specified slot with the specified items (previous items in that slot are lost).

Output[edit]

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
anyJava EditionOn fail000
/replaceitem block ...On success111
/replaceitem entity ...On success11the number of entities whose items are successfully replaced
anyBedrock EditionOn fail0N/AN/A
/replaceitem block ...On success1N/AN/A
/replaceitem entity ...On successthe number of entities whose items are successfully replacedN/AN/A

Examples[edit]

  • To replace the items in the bottom-right slot of a single chest two block above with four spruce saplings:
    • replaceitem block ~ ~2 ~ container.26 minecraft:spruce_sapling 4[Java Edition only]
    • replaceitem block ~ ~2 ~ slot.container 26 sapling 4 1[Bedrock Edition only]
  • To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
    • replaceitem entity @p hotbar.8 minecraft:spruce_sapling 4[Java Edition only]
    • replaceitem entity @p slot.hotbar 8 sapling 4 1[Bedrock Edition only]

Inventory Slot Id Minecraft

History[edit]

Java Edition
1.814w26aAdded /replaceitem.
1.1418w43a/replaceitem can now be used on item frames.
Upcoming Java Edition
1.1720w46aRemoved /replaceitem. Replaced with /item replace.
Pocket Edition
1.0.5alpha 1.0.5.0Added /replaceitem.
1.1.0alpha 1.1.0.0CanPlaceOn and CanDestroy functions are now supported for /replaceitem.
Bedrock Edition
1.16.0beta 1.16.0.55 Added new overload for /replaceitem with an option for destroy or keep.

See also[edit]

Inventory Slot Id Minecraft Bedrock

  • /blockdata — can also replace items in a container
  • /entitydata — can also replace items in a mob's inventory, or modify the drop chances of armor and weapons
  • /give — give items to players without specifying specific inventory slots or overwriting other items
Retrieved from 'https://minecraft.gamepedia.com/Commands/replaceitem?oldid=1781451'