Bukkit Inventory Slot Numbers
API types You may obtain the IDs either by calling GetInventorySlotInfo, ContainerIDToInventoryID, or from the table below. Note that you should never use these values in AddOns, since they may change. Use GetInventorySlotInfo (invSlotName) to get the current mapping. This list is only meant to be used as a reference for reverse mapping while debugging, or possibly for use in macros. In Bukkit, inventory view slots are referenced by slot IDs. However, there are many types of inventory views, which can lead to confusion of which ID belongs to which slot. This page shows all raw slot IDs of all inventory views for ease of reference. Inventory views are sorted alphabetically. The inventory consists of 4 armor slots, 27 storage slots, 9 hotbar slots, and an off-hand slot. Items in the hotbar slots can be selected during play using the keyboard (keys 1 – 9) or mouse wheel and placed or wielded with the mouse buttons. Most items can stack up to a maximum of 64 in one slot. Player.getInventory.setSlot(slotnumber, itemstack) you can iterate through slot numbers and set them to items with names/amounts to figure out Bukkit slot numbers. #4 andrew28, Jul 27, 2016 + Quote Reply.
- Class
Interface Inventory
Bukkit Inventory Slot Numbers 2020
- All Superinterfaces:
Iterable<ItemStack>
- All Known Subinterfaces:
AbstractHorseInventory
,AnvilInventory
,ArmoredHorseInventory
,BeaconInventory
,BrewerInventory
,CraftingInventory
,DoubleChestInventory
,EnchantingInventory
,FurnaceInventory
,HorseInventory
,LlamaInventory
,MerchantInventory
,PlayerInventory
,SaddledHorseInventory
Interface to the various inventories. Behavior relating toMaterial.AIR
is unspecified.
Method Summary
All MethodsInstance MethodsAbstract MethodsDeprecated Methods Modifier and Type Method Description HashMap<Integer,ItemStack>
addItem(ItemStack... items)
HashMap<Integer,? extends ItemStack>
all(int materialId)
Deprecated.HashMap<Integer,? extends ItemStack>
all(ItemStack item)
Finds all slots in the inventory containing any ItemStacks with the given ItemStack.HashMap<Integer,? extends ItemStack>
all(Material material)
Returns a HashMap with all slots and ItemStacks in the inventory with the given Material.void
clear()
void
clear(int index)
Clears out a particular slot in the index.boolean
contains(int materialId)
Deprecated.boolean
contains(int materialId, int amount)
Deprecated.boolean
contains(ItemStack item)
Checks if the inventory contains any ItemStacks matching the given ItemStack.boolean
contains(ItemStack item, int amount)
Checks if the inventory contains at least the minimum amount specified of exactly matching ItemStacks.boolean
contains(Material material)
Checks if the inventory contains any ItemStacks with the given material.boolean
contains(Material material, int amount)
Checks if the inventory contains any ItemStacks with the given material, adding to at least the minimum amount specified.boolean
containsAtLeast(ItemStack item, int amount)
Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.int
first(int materialId)
Deprecated.int
first(ItemStack item)
Returns the first slot in the inventory containing an ItemStack with the given stack.int
first(Material material)
Finds the first slot in the inventory containing an ItemStack with the given materialint
firstEmpty()
ItemStack[]
getContents()
Returns all ItemStacks from the inventoryInventoryHolder
getHolder()
Gets the block or entity belonging to the open inventoryItemStack
getItem(int index)
Returns the ItemStack found in the slot at the given indexLocation
getLocation()
Get the location of the block or entity which corresponds to this inventory.int
getMaxStackSize()
Returns the maximum stack size for an ItemStack in this inventory.String
getName()
int
getSize()
Returns the size of the inventoryItemStack[]
getStorageContents()
Return the contents from the section of the inventory where items can reasonably be expected to be stored.String
getTitle()
InventoryType
getType()
Returns what type of inventory this is.List<HumanEntity>
getViewers()
ListIterator<ItemStack>
iterator()
ListIterator<ItemStack>
iterator(int index)
Returns an iterator starting at the given index.void
remove(int materialId)
Deprecated.void
remove(ItemStack item)
Removes all stacks in the inventory matching the given stack.void
remove(Material material)
Removes all stacks in the inventory matching the given material.HashMap<Integer,ItemStack>
removeItem(ItemStack... items)
void
setContents(ItemStack[] items)
Completely replaces the inventory's contents.void
setItem(int index, ItemStack item)
Stores the ItemStack at the given index of the inventory.void
setMaxStackSize(int size)
This method allows you to change the maximum stack size for an inventory.void
setStorageContents(ItemStack[] items)
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Method Detail
getSize
- Returns:
- The size of the inventory
getMaxStackSize
Returns the maximum stack size for an ItemStack in this inventory.- Returns:
- The maximum size for an ItemStack in this inventory.
setMaxStackSize
This method allows you to change the maximum stack size for an inventory.Caveats:
- Not all inventories respect this value.
- Stacks larger than 127 may be clipped when the world is saved.
- This value is not guaranteed to be preserved; be sure to set it before every time you want to set a slot over the max stack size.
- Stacks larger than the default max size for this type of inventory may not display correctly in the client.
- Parameters:
size
- The new maximum stack size for items in this inventory.
getName
- Returns:
- The String with the name of the inventory
getItem
Returns the ItemStack found in the slot at the given index- Parameters:
index
- The index of the Slot's ItemStack to return- Returns:
- The ItemStack in the slot
setItem
Stores the ItemStack at the given index of the inventory.- Parameters:
index
- The index where to put the ItemStackitem
- The ItemStack to set
addItem
Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.The returned HashMap contains what it couldn't store, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all items are stored, it will return an empty HashMap.
If you pass in ItemStacks which exceed the maximum stack size for the Material, first they will be added to partial stacks where Material.getMaxStackSize() is not exceeded, up to Material.getMaxStackSize(). When there are no partial stacks left stacks will be split on Inventory.getMaxStackSize() allowing you to exceed the maximum stack size for that material.
It is known that in some implementations this method will also set the inputted argument amount to the number of that item not placed in slots.
- Parameters:
items
- The ItemStacks to add- Returns:
- A HashMap containing items that didn't fit.
- Throws:
IllegalArgumentException
- if items or any element in it is null
removeItem
Removes the given ItemStacks from the inventory.It will try to remove 'as much as possible' from the types and amounts you give as arguments.
The returned HashMap contains what it couldn't remove, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all the given ItemStacks are removed, it will return an empty HashMap.
It is known that in some implementations this method will also set the inputted argument amount to the number of that item not removed from slots.
- Parameters:
items
- The ItemStacks to remove- Returns:
- A HashMap containing items that couldn't be removed.
- Throws:
IllegalArgumentException
- if items is null
getContents
- Returns:
- An array of ItemStacks from the inventory.
setContents
Completely replaces the inventory's contents. Removes all existing contents and replaces it with the ItemStacks given in the array.- Parameters:
items
- A complete replacement for the contents; the length must be less than or equal togetSize()
.- Throws:
IllegalArgumentException
- If the array has more items than the inventory.
getStorageContents
Return the contents from the section of the inventory where items can reasonably be expected to be stored. In most cases this will represent the entire inventory, but in some cases it may exclude armor or result slots.
It is these contents which will be used for add / contains / remove methods which look for a specific stack.- Returns:
- inventory storage contents
setStorageContents
- Parameters:
items
- The ItemStacks to use as storage contents- Throws:
IllegalArgumentException
- If the array has more items than the inventory.
contains
Deprecated.Checks if the inventory contains any ItemStacks with the given materialId- Parameters:
materialId
- The materialId to check for- Returns:
- true if an ItemStack in this inventory contains the materialId
contains
Checks if the inventory contains any ItemStacks with the given material.- Parameters:
material
- The material to check for- Returns:
- true if an ItemStack is found with the given Material
- Throws:
IllegalArgumentException
- if material is null
contains
Checks if the inventory contains any ItemStacks matching the given ItemStack.This will only return true if both the type and the amount of the stack match.
- Parameters:
item
- The ItemStack to match against- Returns:
- false if item is null, true if any exactly matching ItemStacks were found
contains
Deprecated.Checks if the inventory contains any ItemStacks with the given materialId, adding to at least the minimum amount specified.- Parameters:
materialId
- The materialId to check foramount
- The minimum amount to look for- Returns:
- true if this contains any matching ItemStack with the given materialId and amount
contains
Checks if the inventory contains any ItemStacks with the given material, adding to at least the minimum amount specified.- Parameters:
material
- The material to check foramount
- The minimum amount- Returns:
- true if amount is less than 1, true if enough ItemStacks were found to add to the given amount
- Throws:
IllegalArgumentException
- if material is null
contains
Checks if the inventory contains at least the minimum amount specified of exactly matching ItemStacks.An ItemStack only counts if both the type and the amount of the stack match.
- Parameters:
item
- the ItemStack to match againstamount
- how many identical stacks to check for- Returns:
- false if item is null, true if amount less than 1, true if amount of exactly matching ItemStacks were found
- See Also:
containsAtLeast(ItemStack, int)
containsAtLeast
Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.- Parameters:
item
- the ItemStack to match againstamount
- the minimum amount- Returns:
- false if item is null, true if amount less than 1, true if enough ItemStacks were found to add to the given amount
all
Deprecated.Returns a HashMap with all slots and ItemStacks in the inventory with given materialId.The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack with the given materialId is found, an empty map is returned.
- Parameters:
materialId
- The materialId to look for- Returns:
- A HashMap containing the slot index, ItemStack pairs
all
Returns a HashMap with all slots and ItemStacks in the inventory with the given Material.The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack with the given Material is found, an empty map is returned.
- Parameters:
material
- The material to look for- Returns:
- A HashMap containing the slot index, ItemStack pairs
- Throws:
IllegalArgumentException
- if material is null
all
Finds all slots in the inventory containing any ItemStacks with the given ItemStack. This will only match slots if both the type and the amount of the stack matchThe HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack with the given Material is found, an empty map is returned.
- Parameters:
item
- The ItemStack to match against- Returns:
- A map from slot indexes to item at index
first
Deprecated.Finds the first slot in the inventory containing an ItemStack with the given materialId.- Parameters:
materialId
- The materialId to look for- Returns:
- The slot index of the given materialId or -1 if not found
first
Finds the first slot in the inventory containing an ItemStack with the given material- Parameters:
material
- The material to look for- Returns:
- The slot index of the given Material or -1 if not found
- Throws:
IllegalArgumentException
- if material is null
first
Returns the first slot in the inventory containing an ItemStack with the given stack. This will only match a slot if both the type and the amount of the stack match- Parameters:
item
- The ItemStack to match against- Returns:
- The slot index of the given ItemStack or -1 if not found
firstEmpty
- Returns:
- The first empty Slot found, or -1 if no empty slots.
remove
Deprecated.Removes all stacks in the inventory matching the given materialId.- Parameters:
materialId
- The material to remove
remove
Removes all stacks in the inventory matching the given material.- Parameters:
material
- The material to remove- Throws:
IllegalArgumentException
- if material is null
remove
Removes all stacks in the inventory matching the given stack.This will only match a slot if both the type and the amount of the stack match
- Parameters:
item
- The ItemStack to match against
clear
- Parameters:
index
- The index to empty.
clear
Clears out the whole Inventory.
getViewers
Gets a list of players viewing the inventory. Note that a player is considered to be viewing their own inventory and internal crafting screen even when said inventory is not open. They will normally be considered to be viewing their inventory even when they have a different inventory screen open, but it's possible for customized inventory screens to exclude the viewer's inventory, so this should never be assumed to be non-empty.- Returns:
- A list of HumanEntities who are viewing this Inventory.
getTitle
- Returns:
- A String with the title.
getType
Returns what type of inventory this is.- Returns:
- The InventoryType representing the type of inventory.
getHolder
Gets the block or entity belonging to the open inventory- Returns:
- The holder of the inventory; null if it has no holder.
iterator
- Specified by:
iterator
in interfaceIterable<ItemStack>
iterator
Returns an iterator starting at the given index. If the index is positive, then the first call to next() will return the item at that index; if it is negative, the first call to previous will return the item at index (getSize() + index).- Parameters:
index
- The index.- Returns:
- An iterator.
getLocation
Get the location of the block or entity which corresponds to this inventory. May return null if this container was custom created or is a virtual / subcontainer.- Returns:
- location or null if not applicable.
- Class
- Summary:
- Nested
- Field
- Constr
- Detail:
- Field
- Constr
Bukkit Inventory Slot Numbers Free
Copyright © 2019. All rights reserved.
Bukkit Inventory Slot Numbers List
Enum Constant | Description |
---|---|
ANVIL | An anvil inventory, with 2 CRAFTING slots and 1 RESULT slot |
BARREL | A barrel box inventory, with 27 slots of type CONTAINER. |
BEACON | |
BLAST_FURNACE | A blast furnace inventory, with a RESULT slot, a CRAFTING slot, and aFUEL slot. |
BREWING | A brewing stand inventory, with one FUEL slot and four CRAFTING slots. |
CARTOGRAPHY | Cartography inventory with 2 CRAFTING slots, and 1 RESULT slot. |
CHEST | A chest inventory, with 0, 9, 18, 27, 36, 45, or 54 slots of typeCONTAINER. |
CRAFTING | A player's crafting inventory, with 4 CRAFTING slots and a RESULT slot. |
CREATIVE | The creative mode inventory, with only 9 QUICKBAR slots and nothingelse. |
DISPENSER | A dispenser inventory, with 9 slots of type CONTAINER. |
DROPPER | A dropper inventory, with 9 slots of type CONTAINER. |
ENCHANTING | An enchantment table inventory, with two CRAFTING slots and threeenchanting buttons. |
ENDER_CHEST | |
FURNACE | A furnace inventory, with a RESULT slot, a CRAFTING slot, and a FUELslot. |
GRINDSTONE | Grindstone inventory with 2 CRAFTING slots, and 1 RESULT slot. |
HOPPER | A hopper inventory, with 5 slots of type CONTAINER. |
LECTERN | |
LOOM | Loom inventory, with 3 CRAFTING slots, and 1 RESULT slot. |
MERCHANT | The merchant inventory, with 2 CRAFTING slots, and 1 RESULT slot. |
PLAYER | A player's inventory, with 9 QUICKBAR slots, 27 CONTAINER slots, 4 ARMORslots and 1 offhand slot. |
SHULKER_BOX | A shulker box inventory, with 27 slots of type CONTAINER. |
SMITHING | A smithing inventory, with 2 CRAFTING slots and 1 RESULT slot |
SMOKER | A smoker inventory, with a RESULT slot, a CRAFTING slot, and a FUEL slot. |
STONECUTTER | Stonecutter inventory with 1 CRAFTING slot, and 1 RESULT slot. |
WORKBENCH | A workbench inventory, with 9 CRAFTING slots and a RESULT slot. |