mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-22 04:52:15 +00:00
Inventory support for itemstacklist
This commit is contained in:
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
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user