Inventory support for itemstacklist

This commit is contained in:
Bernhard Bonigl committed 2017-04-30 10:46:39 +02:00
1 parent eaee115cc5
commit b4a223b6ae
1 file changed
+12
@@ -1,5 +1,6 @@
package slimeknights.mantle.util;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
@@ -49,6 +50,17 @@ public class ItemStackList extends NonNullList<ItemStack> {
return itemStackList;
}
/**
* Create an ItemStackList from the given elements.
*/
public static ItemStackList of(IInventory inventory) {
ItemStackList itemStackList = withSize(inventory.getSizeInventory());
for(int i = 0; i < inventory.getSizeInventory(); i++) {
itemStackList.add(inventory.getStackInSlot(i));
}
return itemStackList;
}
/**
* Checks if an Itemstack at a specific index is not empty
*