Bukkit Inventory Slot Numbers Youtube
- 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
Configuration info: shop-lines: 3 # Number of shop GUI lines. Maximum is 6 (54 slots) fill-empty: true # Put items in free inventory slot instead of adding items to existing stack. 'INKSACK-3': # ItemName-Durability (-durability is optional) amount: 2 # Amount of items to add to player inventory when buy. 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. 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. /useitem slot subindex Please Note: subitem is only used if the item is in a bag.Bag slot numbers start at 0, and go up left to right, top to bottom. Here's an easy example to use (i.e. Click) your right ring clickie. 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.
-
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.
-
- All Superinterfaces:
Iterable
Bukkit Inventory Slot Numbers Youtube
- 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
Configuration info: shop-lines: 3 # Number of shop GUI lines. Maximum is 6 (54 slots) fill-empty: true # Put items in free inventory slot instead of adding items to existing stack. 'INKSACK-3': # ItemName-Durability (-durability is optional) amount: 2 # Amount of items to add to player inventory when buy. 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. 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. /useitem slot subindex Please Note: subitem is only used if the item is in a bag.Bag slot numbers start at 0, and go up left to right, top to bottom. Here's an easy example to use (i.e. Click) your right ring clickie. 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.
-
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.
-
- All Superinterfaces:
Iterable
- All Known Subinterfaces:
AbstractHorseInventory
,AnvilInventory
,BeaconInventory
,BrewerInventory
,CartographyInventory
,CraftingInventory
,DoubleChestInventory
,EnchantingInventory
,FurnaceInventory
,GrindstoneInventory
,HorseInventory
,LecternInventory
,LlamaInventory
,LoomInventory
,MerchantInventory
,PlayerInventory
,SmithingInventory
,StonecutterInventory
Material.AIR
is unspecified.Note that whilst
iterator()
deals with the entire inventory, add/ contains / remove methods deal only with the storage contents.Consider using
getContents()
and getStorageContents()
forspecific iteration.Bukkit Inventory Slot Numbers List
- See Also:
getContents()
,getStorageContents()
Bukkit Inventory Slot Numbers Free
-
Method Summary
Modifier and Type Method Description HashMap
addItem(ItemStack.. items)
HashMap
all(ItemStack item)
Finds all slots in the inventory containing any ItemStacks with thegiven ItemStack.HashMap
all(Material material)
Returns a HashMap with all slots and ItemStacks in the inventory withthe given Material.void
clear()
void
clear(int index)
Clears out a particular slot in the index.boolean
contains(ItemStack item)
Checks if the inventory contains any ItemStacks matching the givenItemStack.boolean
contains(ItemStack item,int amount)
Checks if the inventory contains at least the minimum amount specifiedof exactly matching ItemStacks.boolean
contains(Material material)
Checks if the inventory contains any ItemStacks with the givenmaterial.boolean
contains(Material material,int amount)
Checks if the inventory contains any ItemStacks with the givenmaterial, adding to at least the minimum amount specified.boolean
containsAtLeast(ItemStack item,int amount)
Checks if the inventory contains ItemStacks matching the givenItemStack whose amounts sum to at least the minimum amount specified.int
first(ItemStack item)
Returns the first slot in the inventory containing an ItemStack withthe given stack.int
first(Material material)
Finds the first slot in the inventory containing an ItemStack with thegiven 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.int
getSize()
ItemStack[]
getStorageContents()
Return the contents from the section of the inventory where items canreasonably be expected to be stored.InventoryType
getType()
List
getViewers()
Gets a list of players viewing the inventory.boolean
isEmpty()
ListIterator
iterator()
ListIterator
iterator(int index)
Returns an iterator starting at the given index.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
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 aninventory.void
setStorageContents(ItemStack[] items)
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Bukkit Inventory Slot Numbers 2020
-
Method Details
-
getSize
Returns the size of the inventory- 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 aninventory.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 itbefore every time you want to set a slot over the max stack size.
- Stacks larger than the default max size for this type of inventorymay not display correctly in the client.
- Parameters:
size
- The new maximum stack size for items in this 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
@NotNullHashMapaddItem(@NotNullItemStack.. items)throws IllegalArgumentExceptionStores the given ItemStacks in the inventory. This will try to fillexisting stacks and empty slots as well as it can.The returned HashMap contains what it couldn't store, where the key isthe index of the parameter, and the value is the ItemStack at thatindex of the varargs parameter. If all items are stored, it will returnan empty HashMap.
If you pass in ItemStacks which exceed the maximum stack size for theMaterial, first they will be added to partial stacks whereMaterial.getMaxStackSize() is not exceeded, up toMaterial.getMaxStackSize(). When there are no partial stacks leftstacks will be split on Inventory.getMaxStackSize() allowing you toexceed the maximum stack size for that material. Slot machine apps where you can win real money.
It is known that in some implementations this method will also setthe inputted argument amount to the number of that item not placed inslots.
- 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
@NotNullHashMapremoveItem(@NotNullItemStack.. items)throws IllegalArgumentExceptionRemoves the given ItemStacks from the inventory.It will try to remove 'as much as possible' from the types and amountsyou give as arguments.
The returned HashMap contains what it couldn't remove, where the key isthe index of the parameter, and the value is the ItemStack at thatindex of the varargs parameter. If all the given ItemStacks areremoved, it will return an empty HashMap.
It is known that in some implementations this method will also set theinputted argument amount to the number of that item not removed fromslots.
- Parameters:
items
- The ItemStacks to remove- Returns:
- A HashMap containing items that couldn't be removed.
- Throws:
IllegalArgumentException
- if items is null
-
getContents
Returns all ItemStacks from the inventory- Returns:
- An array of ItemStacks from the inventory. Individual items may be null.
-
setContents
voidsetContents(@NotNullItemStack[] items)throws IllegalArgumentExceptionCompletely replaces the inventory's contents. Removes all existingcontents and replaces it with the ItemStacks given in the array.- Parameters:
items
- A complete replacement for the contents; the length mustbe less than or equal togetSize()
.- Throws:
IllegalArgumentException
- If the array has more items than theinventory.
-
getStorageContents
Return the contents from the section of the inventory where items canreasonably be expected to be stored. In most cases this will representthe entire inventory, but in some cases it may exclude armor or resultslots.
It is these contents which will be used for add / contains / removemethods which look for a specific stack.- Returns:
- inventory storage contents. Individual items may be null.
-
setStorageContents
voidsetStorageContents(@NotNullItemStack[] items)throws IllegalArgumentException- Parameters:
items
- The ItemStacks to use as storage contents- Throws:
IllegalArgumentException
- If the array has more items than theinventory.
-
contains
booleancontains(@NotNullMaterial material)throws IllegalArgumentExceptionChecks if the inventory contains any ItemStacks with the givenmaterial.- 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
@Contract('null -> false')booleancontains(@NullableItemStack item)Checks if the inventory contains any ItemStacks matching the givenItemStack.This will only return true if both the type and the amount of the stackmatch.
- Parameters:
item
- The ItemStack to match against- Returns:
- false if item is null, true if any exactly matching ItemStackswere found
-
contains
booleancontains(@NotNullMaterial material,int amount)throws IllegalArgumentExceptionChecks if the inventory contains any ItemStacks with the givenmaterial, 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 werefound to add to the given amount
- Throws:
IllegalArgumentException
- if material is null
-
contains
@Contract('null, _ -> false')booleancontains(@NullableItemStack item,int amount)Checks if the inventory contains at least the minimum amount specifiedof exactly matching ItemStacks.An ItemStack only counts if both the type and the amount of the stackmatch.
- 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 ifamount of exactly matching ItemStacks were found
- See Also:
containsAtLeast(ItemStack, int)
-
containsAtLeast
@Contract('null, _ -> false')booleancontainsAtLeast(@NullableItemStack item,int amount)Checks if the inventory contains ItemStacks matching the givenItemStack 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 ifenough ItemStacks were found to add to the given amount
-
all
@NotNullHashMapall(@NotNullMaterial material)throws IllegalArgumentExceptionReturns a HashMap with all slots and ItemStacks in the inventory withthe given Material.The HashMap contains entries where, the key is the slot index, and thevalue is the ItemStack in that slot. If no matching ItemStack with thegiven 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
@NotNullHashMapall(@NullableItemStack item)Finds all slots in the inventory containing any ItemStacks with thegiven ItemStack. This will only match slots if both the type and theamount of the stack matchThe HashMap contains entries where, the key is the slot index, and thevalue is the ItemStack in that slot. If no matching ItemStack with thegiven 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
intfirst(@NotNullMaterial material)throws IllegalArgumentExceptionFinds the first slot in the inventory containing an ItemStack with thegiven 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 withthe given stack. This will only match a slot if both the type and theamount 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.- Returns:
- The first empty Slot found, or -1 if no empty slots.
-
isEmpty
Check whether or not this inventory is empty. An inventory is consideredto be empty if there are no ItemStacks in any slot of this inventory.- Returns:
- true if empty, false otherwise
-
remove
voidremove(@NotNullMaterial material)throws IllegalArgumentExceptionRemoves 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 thestack match
- Parameters:
item
- The ItemStack to match against
-
clear
Clears out a particular slot in the index.- 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 isconsidered to be viewing their own inventory and internal craftingscreen even when said inventory is not open. They will normally beconsidered to be viewing their inventory even when they have adifferent inventory screen open, but it's possible for customizedinventory screens to exclude the viewer's inventory, so this shouldnever be assumed to be non-empty.- Returns:
- A list of HumanEntities who are viewing this Inventory.
-
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
-
iterator
@NotNullListIteratoriterator(int index)Returns an iterator starting at the given index. If the index ispositive, then the first call to next() will return the item at thatindex; if it is negative, the first call to previous will return theitem 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 containerwas custom created or is a virtual / subcontainer.- Returns:
- location or null if not applicable.
-