public interface IItemSource
| Modifier and Type | Method and Description |
|---|---|
static IItemSource |
fromInventory(IInventory inv)
Construct an IItemSource from given inventory
|
static IItemSource |
fromPlayer(EntityPlayerMP player)
Construct an IItemSource from inventories associated with given player.
|
Map<ItemStack,Integer> |
take(Predicate<ItemStack> predicate,
boolean simulate,
int count)
Retrieve some amount of items from this item source matching given filter.
|
default boolean |
takeAll(ItemStack stack,
boolean simulate)
Take some item.
|
default boolean |
takeAll(Predicate<ItemStack> predicate,
boolean simulate,
int count)
Take exactly count amount of items matching predicate.
|
default boolean |
takeOne(ItemStack stack,
boolean simulate)
Take exactly one item.
|
default ItemStack |
takeOne(Predicate<ItemStack> predicate,
boolean simulate)
Take exactly one item that matches the predicate.
|
@Nonnull Map<ItemStack,Integer> take(Predicate<ItemStack> predicate, boolean simulate, int count)
We probably don't need to get a lot of items from this method, so I don't care about the overhead of storing all fetched items even if downstream code doesn't need it
predicate - filtering predicate. should return true for ItemStacks that should be added to result collectionsimulate - whether to actually commit the modification. true for dry run, false otherwise.count - how many items to extract.default ItemStack takeOne(Predicate<ItemStack> predicate, boolean simulate)
predicate - filtering predicate. should return true for ItemStacks that should be added to result collectionsimulate - whether to actually commit the modification. true for dry run, false otherwise.IllegalArgumentException - if given predicate is null.default boolean takeAll(Predicate<ItemStack> predicate, boolean simulate, int count)
predicate - filtering predicate. should return true for ItemStacks that should be added to result collectionsimulate - whether to actually commit the modification. true for dry run, false otherwise.count - how many items to extract.IllegalArgumentException - if given predicate is nulldefault boolean takeOne(ItemStack stack, boolean simulate)
This is meant to be an optimized version of takeOne(Predicate, boolean). Implementations that support
item storage indexed by ItemStack can use this to speed up calculation.
stack - what item to extract. The NBT tag of this ItemStack is siginifcant and will be considered during
matching. must have a stack size of 1.simulate - whether to actually commit the modification. true for dry run, false otherwise.IllegalArgumentException - if given stack is invalid, or has a stack size other than 1.default boolean takeAll(ItemStack stack, boolean simulate)
This is meant to be an optimized version of takeOne(Predicate, boolean). Implementations that support
indexing off ItemStack can use this to speed up calculation.
stack - what item and how many to extract. The NBT tag of this ItemStack is siginifcant and will be
considered during matchingsimulate - whether to actually commit the modification. true for dry run, false otherwise.IllegalArgumentException - if given stack is invalidstatic IItemSource fromPlayer(EntityPlayerMP player)
This will be backed by InventoryUtility
static IItemSource fromInventory(IInventory inv)
This will be backed by InventoryUtility