{10} Items and ItemContainers (Inventory, Bank, Equipment, Store, ...)
Items such as "Logs" and "Bones" are represented by the Item class
The Item class provides various different useful methods such as getName() to return the name of an item, getAmount() to return the amount of the item (e.g. the amount of the item in your inventory, or the amount of the item in the bank), isNote() and getActions() which returns a String[] of all the possible actions your player could perform on the item.
Like with the Entity class, the Item class implements the Interactable interface, which provides you with an interact(String interaction) method.
So in the same way as you would interact with a Tree Entity to chop it down, you can interact with an Item, for example to eat it.
Items are stored inside of ItemContainers, and so to retrieve an instance of Item you must retrieve it from the relevant ItemContainer.
The current available ItemContainers are: Bank, DepositBox, Equipment, Inventory, Store, Trade.OurOffer, Trade.TheirOffer
You can retrieve the instances of these ItemContainers using the associated getter methods in the MethodProvider class:
Note that, getBank() and getDepositBox() will both return null if your player is not close to a bank or deposit box, and so you must check that the returned instance is not null before calling any methods on it.
All of the ItemContainers share the same useful methods:
But each of the classes that extend ItemContainer will have some extra methods added to them. For example, the Bank class also defines the methods:
Both the Bank and DepositBox require you to open them before you can use any of the methods.
Here is an example of using an ItemContainer, getting a Lobster item from the Inventory and eating it: