Minecraft displays the player inventory differently, according to how the window was opened. Ranges of slot indices vary in meaning between different 'windows'. The Open Window packet indicates which window is being opened according to:
It follows the same path in the inventory like you would read a book. Indexes 36 through 39 refer to the armor slots. Though you can set armor with this method using these indexes, you are encouraged to use the provided methods for those slots. Index 40 refers to the off hand (shield) item slot. For each individual inventory slot, you can add items to a list. These items can now either be blacklisted (i.e. Every other item than those in the list goes into the slot), or whitelisted (i.e. Only the items listed fit into the slot). Your players inventory is still a bit too big? Itemslotmachine.command.slot.build /slot remove Removes an existing slot machine: itemslotmachine.command.slot.remove /slot list: Displays a list of all available slot machines: itemslotmachine.command.slot.list /slot tp Teleports the player to a slot machine: itemslotmachine.command.slot.tp /slot rebuild Rebuilds a broken.
- 2Chest
- 4Furnace
Window Type | Description |
---|---|
minecraft:generic_9x1 | A 1-row inventory, not used by the notchian server. |
minecraft:generic_9x2 | A 2-row inventory, not used by the notchian server. |
minecraft:generic_9x3 | General-purpose 3-row inventory. Used by Chest, minecart with chest, ender chest, and barrel |
minecraft:generic_9x4 | A 4-row inventory, not used by the notchian server. |
minecraft:generic_9x5 | A 5-row inventory, not used by the notchian server. |
minecraft:generic_9x6 | General-purpose 6-row inventory, used by large chests. |
minecraft:generic_3x3 | General-purpose 3-by-3 square inventory, used by Dispenser and Dropper |
minecraft:anvil | Anvil |
minecraft:beacon | Beacon |
minecraft:blast_furnace | Blast Furnace |
minecraft:brewing_stand | Brewing stand |
minecraft:crafting | Crafting table |
minecraft:enchantment | Enchantment table |
minecraft:furnace | Furnace |
minecraft:grindstone | Grindstone |
minecraft:hopper | Hopper or minecart with hopper |
minecraft:lectern | Lectern |
minecraft:loom | Loom |
minecraft:merchant | Villager, Wandering Trader |
minecraft:shulker_box | Shulker box |
minecraft:smoker | Smoker |
minecraft:cartography | Cartography Table |
minecraft:stonecutter | Stonecutter |
The following information needs to be added to this page: |
Most of the inventories new to 1.14 have buttons, which are probably implemented using Protocol#Click Window Button. This needs to be confirmed and the button IDs should be checked. |
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.
The default inventory window, which is never explicitly opened by the server, has 10 unique slots.
Rectangular regions are always indexed starting with the upper-left corner and scanning across rows. If a window has a crafting region, the output slot is always slot 0 followed immediately by the input region.
Each window type is described in the following sections. All slot index ranges are inclusive and reflect the indices observed in the Minecraft protocol.
For the window properties (additional data in each window, e.g. smelting progress or enchantments), refer to the table in the Window Property packet.
Using -1 as slot index and as window id will set the cursor item (the stack dragged with the mouse).
Player Inventory
This is the inventory window that the player can always open, typically by pressing E since Beta 1.4. Before, you had to press I.
Slot range | Description |
---|---|
0 | crafting output |
1–4 | 2×2 crafting input (1 + x + 2 * y) |
5–8 | armor (head, chest, legs, feet) |
9–35 | main inventory |
36–44 | hotbar |
45 | Offhand slot |
Note that this is different from inventory items stored in a player.dat file. This may help: https://gist.github.com/459a1691c3dd751db160
Chest
This is the window that is opened when the player right-clicks on a single chest block.
Slot range | Description |
---|---|
0–26 | chest |
27–53 | main inventory |
54–62 | hotbar |
Large chest
This is the window that is opened when the player right-clicks on a double chest block (two adjacent chest blocks).
Slot range | Description |
---|---|
0–53 | chest |
54–80 | main inventory |
81–89 | hotbar |
It is possible to receive different 'Number Of Slots' parameters than those two. In vanilla, using /setblock four times around a chest and then opening the middle chest will open a window with 5*27 chest slots. Some custom servers will send chest inventories with other sizes, usually ranging from 1 row to 6 rows. These may be used for custom GUIs. It is thus important to correctly use the 'Number Of Slots' parameter in the open window packet to determine the number of rows in the chest, rather than hardcoding what constitutes a regular chest or a large chest.
Crafting table
This is the window that is opened when the player right-clicks on a workbench.
Slot range | Description |
---|---|
0 | crafting output |
1–9 | 3×3 crafting input (1 + x + 3 * y) |
10–36 | main inventory |
37–45 | hotbar |
If the 'Number Of Slots' parameter is not set to 0, the opened window will behave like a container window.
Furnace
The window that appears when a furnace is right-clicked.
Slot range | Description |
---|---|
0 | ingredient |
1 | fuel |
2 | output |
3–29 | main inventory |
30–38 | hotbar |
If the 'Number Of Slots' parameter is inferior to 3, placing an item in a slot may crash the client.
Blast Furnace
The GUI that appears when a blast furnace is opened. Same layout as a furnace; however, the recipe book displays blast furnace recipes instead of regular furnace recipes.
Slot range | Description |
---|---|
0 | ingredient |
1 | fuel |
2 | output |
3–29 | main inventory |
30–38 | hotbar |
Smoker
The GUI that appears when a smoker is opened. Same layout as a furnace; however, the recipe book displays blast furnace recipes instead of regular furnace recipes.
Slot range | Description |
---|---|
0 | ingredient |
1 | fuel |
2 | output |
3–29 | main inventory |
30–38 | hotbar |
Dispenser
The inventory that appears when a dispenser or dropper is opened.
Slot range | Description |
---|---|
0–8 | 3×3 dispenser contents (x + 3 * y) |
9–35 | main inventory |
36-44 | hotbar |
If the 'Number Of Slots' parameter is inferior to 9, placing an item in a slot may crash the client.
Enchantment Table
The inventory of an enchantment table. The enchant buttons trigger a Enchant item packet.
Slot range | Description |
---|---|
0 | item to enchant |
1 | lapis lazuli slot |
2–28 | main inventory |
29–37 | hotbar |
Brewing stand
The GUI that appears when a brewing stand is opened.
Slot range | Description |
---|---|
0-2 | bottles/potions |
3 | potion ingredient |
4 | blaze powder |
5-31 | main inventory |
32-40 | hotbar |
Villager trading
The GUI that appears when a villager is right-clicked. Note that if the villager only requires one item, you can put it in either (or both) slots.
Slot range | Description |
---|---|
0-1 | input items |
2 | result |
3–29 | main inventory |
30–38 | hotbar |
Beacon
The window that appears when a beacon is right-clicked.
Slot range | Description |
---|---|
0 | payment item |
1–27 | main inventory |
28–36 | hotbar |
Anvil
Slot range | Description |
---|---|
0 | first item |
1 | second item |
2 | result |
3–29 | main inventory |
30–38 | hotbar |
Hopper
The window that appears when a hopper or hopper minecart is opened.
Inventory Slot Plugin Minecraft 1.12.2
Slot range | Description |
---|---|
0-4 | hopper slots |
5–31 | main inventory |
32–40 | hotbar |
Shulker box
This is the window that is opened when the player right-clicks on a shulker box chest.
Slot range | Description |
---|---|
0–26 | box slots |
27–53 | main inventory |
54–62 | hotbar |
Llama
Inventory Slot Plugin Minecraft 1.8.9
The inventory that appears when a tamed llama is right-clicked and has a chest, or when the player's inventory is opened while riding a tamed llama. Depending on the value of the strength field, the number of chest rows may vary (max is 5, so 15 slots).
There still is a saddle slot, even though it cannot be used and is invisible.
Slot positions within the llama inventory vary - slot 2 may be at (1,0) or at (0,1) depending on the number of columns.
Slot range | Description |
---|---|
0 | saddle |
1 | carpet |
2-(2+3*Strength) | llama inventory |
(2+3*Strength)+1-(2+3*Strength)+27 | player inventory |
(2+3*Strength)+28-(2+3*Strength)+35 | hotbar |
Unchested llama
Llama with strength 1
Llama with strength 2
Llama with strength 3
Llama with strength 4
Llama with strength 5
Horse
The window for when a tamed horse is right-clicked or the player's inventory is opened while riding a horse.
Slot range | Description |
---|---|
0 | saddle |
1 | armor |
2–28 | main inventory |
29–37 | hotbar |
Horse slots
Skeleton horse slots
Zombie horse slots
Donkey
Inventory Slot Plugin Minecraft 1.8
The inventory that appears when a tamed donkey (or mule?) is right-clicked, or when the player's inventory is opened while riding a tamed donkey or mule.
There still is an armor slot, even though it cannot be used and is invisible.
Slot range | Description |
---|---|
0 | saddle |
1 | armor |
2–16 | donkey inventory |
17–43 (2-28 if unchested) | player inventory |
44–52 (29-37 if unchested) | hotbar |
Unchested donkey
Chested donkey
Unchested mule
Chested mule
Cartography Table
The GUI that appears when a cartography table is opened.
Slot range | Description |
---|---|
0 | map |
1 | paper |
2 | output |
3–29 | main inventory |
30–38 | hotbar |
Grindstone
Slot range | Description |
---|---|
0 | first item |
1 | second item |
2 | result |
3–29 | main inventory |
30–38 | hotbar |
Lectern
This is a regular container, unlike with held books opened via Protocol#Open Book. Nvidia single slot gpu.
The following information needs to be added to this page: |
Is the player inventory also included on this? |
Slot range | Description |
---|---|
0 | book |
1–27 | main inventory? |
28–36 | hotbar? |
Loom
Inventory Slot Plugin Minecraft Server
Slot range | Description |
---|---|
0 | banner |
1 | dye |
2 | pattern |
3 | result |
4–30 | main inventory |
31–39 | hotbar |
Stonecutter
Slot range | Description |
---|---|
0 | input |
1 | result |
2–28 | main inventory |
29–37 | hotbar |
- All Superinterfaces:
Inventory
,Iterable
-
Method Summary
Modifier and Type Method Description ItemStack[]
getArmorContents()
ItemStack
getBoots()
Return the ItemStack from the boots slotItemStack
getChestplate()
ItemStack[]
getExtraContents()
Get all additional ItemStacks stored in this inventory.int
getHeldItemSlot()
ItemStack
getHelmet()
Return the ItemStack from the helmet slotHumanEntity
getHolder()
Gets the block or entity belonging to the open inventoryItemStack
getItem(EquipmentSlot slot)
Gets the ItemStack at the given equipment slot in the inventory.ItemStack
getItemInHand()
Deprecated.players can duel wield now use the methods for thespecific hand insteadItemStack
getItemInMainHand()
Gets a copy of the item the player is currently holdingin their main hand.ItemStack
getItemInOffHand()
Gets a copy of the item the player is currently holdingin their off hand.ItemStack
getLeggings()
void
setArmorContents(ItemStack[] items)
Put the given ItemStacks into the armor slotsvoid
setBoots(ItemStack boots)
void
setChestplate(ItemStack chestplate)
Put the given ItemStack into the chestplate slot.void
setExtraContents(ItemStack[] items)
Put the given ItemStacks into the extra slots
SeegetExtraContents()
for an explanation of extra slots.void
setHeldItemSlot(int slot)
void
setHelmet(ItemStack helmet)
Put the given ItemStack into the helmet slot.void
setItem(int index,ItemStack item)
Stores the ItemStack at the given index of the inventory.void
setItem(EquipmentSlot slot,ItemStack item)
Stores the ItemStack at the given equipment slot in the inventory.void
setItemInHand(ItemStack stack)
Deprecated.players can duel wield now use the methods for thespecific hand insteadvoid
setItemInMainHand(ItemStack item)
Sets the item the player is holding in their main hand.void
setItemInOffHand(ItemStack item)
Sets the item the player is holding in their off hand.void
setLeggings(ItemStack leggings)
Methods inherited from interface org.bukkit.inventory.Inventory
addItem, all, all, clear, clear, contains, contains, contains, contains, containsAtLeast, first, first, firstEmpty, getContents, getItem, getLocation, getMaxStackSize, getSize, getStorageContents, getType, getViewers, isEmpty, iterator, iterator, remove, remove, removeItem, setContents, setMaxStackSize, setStorageContents
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
getArmorContents
Get all ItemStacks from the armor slots- Returns:
- All the ItemStacks from the armor slots. Individual items can be null.
-
getExtraContents
Get all additional ItemStacks stored in this inventory.
NB: What defines an extra slot is up to the implementation, however itwill not be contained withinInventory.getStorageContents()
orgetArmorContents()
- Returns:
- All additional ItemStacks. Individual items can be null.
-
getHelmet
Return the ItemStack from the helmet slot- Returns:
- The ItemStack in the helmet slot
-
getChestplate
Return the ItemStack from the chestplate slot- Returns:
- The ItemStack in the chestplate slot
-
getLeggings
Return the ItemStack from the leg slot- Returns:
- The ItemStack in the leg slot
-
getBoots
Return the ItemStack from the boots slot- Returns:
- The ItemStack in the boots slot
-
setItem
Stores the ItemStack at the given index of the inventory.Indexes 0 through 8 refer to the hotbar. 9 through 35 refer to the main inventory, counting up from 9 at the topleft corner of the inventory, moving to the right, and moving to the row below it back on the left side when itreaches the end of the row. It follows the same path in the inventory like you would read a book.
Indexes 36 through 39 refer to the armor slots. Though you can set armor with this method using these indexes,you are encouraged to use the provided methods for those slots.
Index 40 refers to the off hand (shield) item slot. Though you can set off hand with this method using this index,you are encouraged to use the provided method for this slot.
If you attempt to use this method with an index less than 0 or greater than 40, an ArrayIndexOutOfBoundsexception will be thrown.
- Specified by:
setItem
in interfaceInventory
- Parameters:
index
- The index where to put the ItemStackitem
- The ItemStack to set- Throws:
ArrayIndexOutOfBoundsException
- when index < 0 || index > 40- See Also:
setBoots(ItemStack)
,setChestplate(ItemStack)
,setHelmet(ItemStack)
,setLeggings(ItemStack)
,setItemInOffHand(ItemStack)
-
setItem
voidsetItem(@NotNullEquipmentSlot slot,@NullableItemStack item)Stores the ItemStack at the given equipment slot in the inventory.- Parameters:
slot
- the slot to put the ItemStackitem
- the ItemStack to set- See Also:
setItem(int, ItemStack)
-
getItem
@NotNullItemStackgetItem(@NotNullEquipmentSlot slot)Gets the ItemStack at the given equipment slot in the inventory.- Parameters:
slot
- the slot to get the ItemStack- Returns:
- the ItemStack in the given slot
-
setArmorContents
Put the given ItemStacks into the armor slots- Parameters:
items
- The ItemStacks to use as armour
-
setExtraContents
Put the given ItemStacks into the extra slots
SeegetExtraContents()
for an explanation of extra slots.- Parameters:
items
- The ItemStacks to use as extra
-
setHelmet
Put the given ItemStack into the helmet slot. This does not check ifthe ItemStack is a helmet- Parameters:
helmet
- The ItemStack to use as helmet
-
setChestplate
Put the given ItemStack into the chestplate slot. This does not checkif the ItemStack is a chestplate- Parameters:
chestplate
- The ItemStack to use as chestplate
-
setLeggings
Put the given ItemStack into the leg slot. This does not check if theItemStack is a pair of leggings- Parameters:
leggings
- The ItemStack to use as leggings
-
setBoots
Put the given ItemStack into the boots slot. This does not check if theItemStack is a boots- Parameters:
boots
- The ItemStack to use as boots
-
getItemInMainHand
Gets a copy of the item the player is currently holdingin their main hand.- Returns:
- the currently held item
-
setItemInMainHand
Sets the item the player is holding in their main hand.- Parameters:
item
- The item to put into the player's hand
-
getItemInOffHand
Gets a copy of the item the player is currently holdingin their off hand.- Returns:
- the currently held item
-
setItemInOffHand
Sets the item the player is holding in their off hand.- Parameters:
item
- The item to put into the player's hand
-
getItemInHand
Deprecated.players can duel wield now use the methods for thespecific hand insteadGets a copy of the item the player is currently holding- Returns:
- the currently held item
- See Also:
getItemInMainHand()
,getItemInOffHand()
-
setItemInHand
@DeprecatedvoidsetItemInHand(@NullableItemStack stack)Deprecated.players can duel wield now use the methods for thespecific hand instead- Parameters:
stack
- The item to put into the player's hand- See Also:
setItemInMainHand(ItemStack)
,setItemInOffHand(ItemStack)
-
getHeldItemSlot
intgetHeldItemSlot()- Returns:
- Held item slot number
-
setHeldItemSlot
voidsetHeldItemSlot(int slot)Set the slot number of the currently held item.This validates whether the slot is between 0 and 8 inclusive.
- Parameters:
slot
- The new slot number- Throws:
IllegalArgumentException
- Thrown if slot is not between 0 and 8inclusive
-
getHolder
Description copied from interface:Inventory
Gets the block or entity belonging to the open inventory- Specified by:
getHolder
in interfaceInventory
- Returns:
- The holder of the inventory; null if it has no holder.
-