Package de.ellpeck.rockbottom.api.helper
Class InventoryHelper
java.lang.Object
de.ellpeck.rockbottom.api.helper.InventoryHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<ItemInstance>collectItems(IInventory inventory) Collects all the items in the inventory into single item instances even if the inventory has items separated.static intremoveFrom(IInventory inv, IUseInfo item) Attempts to remove the item from the inventory, deducting the amounts from multiple item instances if needed.
-
Constructor Details
-
InventoryHelper
public InventoryHelper()
-
-
Method Details
-
collectItems
Collects all the items in the inventory into single item instances even if the inventory has items separated.For example if you collect the players inventory and it has 1 stick slot with amount set to 5 and 3 stone slots each with amount set to 20, this method will return a list of 2 items, 1 stick with amount set to 5 and 1 stone with amount set to 60.
- Parameters:
inventory- the inventory to collect items from.- Returns:
- The list of items collected into single type instances.
-
removeFrom
Attempts to remove the item from the inventory, deducting the amounts from multiple item instances if needed. For example if you try to remove 14 stone from the players inventory which has 2 instances of 10 stones each, it will first deduct 10 from the first instance and then 6 from the second instance leaving a single item with 4 stone.- Parameters:
inv- The inventory to remove the item fromitem- The item to remove from the inventory- Returns:
- the remaining amount that was not removed from the inventory
-