Inventory

class Inventory : JSONImpl

Constructors

Link copied to clipboard
fun Inventory(inventory: IInventory)
Link copied to clipboard
fun Inventory(container: Container)

Functions

Link copied to clipboard
fun click(slot: Int, shift: Boolean = false, button: String = "LEFT"): Inventory

Shorthand for ClickAction

Link copied to clipboard
fun contains(item: Item): Boolean

Checks whether the inventory contains the given item.

fun contains(id: Int): Boolean

Checks whether the inventory contains an item with ID.

Link copied to clipboard
fun doAction(action: Action)
Link copied to clipboard
fun drag(type: String, vararg slots: Int): Inventory

Shorthand for DragAction

Link copied to clipboard
fun drop(slot: Int, ctrl: Boolean): Inventory

Shorthand for DropAction

Link copied to clipboard
fun getClassName(): String
Link copied to clipboard
fun getItems(): List<Item?>
Link copied to clipboard
fun getName(): String

Gets the name of the inventory, simply "container" for most chest-like blocks.

Link copied to clipboard
fun getSize(): Int

Gets the total size of the Inventory. The player's inventory size is 36, 27 for the main inventory, plus 9 for the hotbar. A single chest's size would be 63, because it also counts the player's inventory.

Link copied to clipboard
fun getStackInSlot(slot: Int): Item?

Gets the item in any slot, starting from 0.

Link copied to clipboard
fun getWindowId(): Int

Returns the window identifier number of this Inventory. This Inventory must be backed by a Container isContainer

Link copied to clipboard
fun indexOf(item: Item): Int

Gets the index of any item in the inventory, and returns the slot number. Returns -1 if the inventory does not contain the item.

fun indexOf(id: Int): Int

Gets the index of any item in the inventory with matching ID, and returns the slot number. Returns -1 if the inventory does not contain the item.

Link copied to clipboard
fun isContainer(): Boolean

Returns true if this Inventory wraps a Container object rather than an IInventory object

Link copied to clipboard
fun isItemValidForSlot(slot: Int, item: Item): Boolean

Checks if an item can be shift clicked into a certain slot, i.e. coal into the bottom of a furnace.

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
val container: Container?
Link copied to clipboard
val inventory: IInventory?

Sources

Link copied to clipboard