Class InventoryUtility
java.lang.Object
com.gtnewhorizon.structurelib.util.InventoryUtility
This class is part of API, but is not stable. Use at your own risk.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInventoryUtility.InventoryProvider<R extends Iterable<ItemStack>>static interfacestatic interfacestatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Iterator<? extends InventoryUtility.ItemStackExtractor> getStackExtractors(EntityPlayerMP player) static voidinit()static <Inv extends IInventory>
InventoryUtility.InventoryProvider<InventoryIterable<Inv>> newInventoryProvider(Function<EntityPlayerMP, ? extends Inv> extractor) newItemStackProvider(Function<ItemStack, ? extends IInventory> extractor) static voidregisterEnableEnderCondition(Predicate<? super EntityPlayerMP> predicate) static voidstatic <Inv extends IInventory>
voidregisterInventoryProvider(String key, Function<EntityPlayerMP, ? extends Inv> extractor) static voidstatic <Inv extends IInventory>
voidregisterStackExtractor(String key, Function<ItemStack, ? extends Inv> extractor) takeFromInventory(Iterable<ItemStack> inv, Predicate<ItemStack> predicate, boolean simulate, int count, boolean recursive) take count amount of stacks that matches given filter.takeFromInventory(EntityPlayerMP player, Predicate<ItemStack> predicate, boolean simulate, int count) take count amount of stacks that matches given filter.static inttakeFromInventory(EntityPlayerMP player, ItemStack filter, boolean simulate) take count amount of stacks that matches given filter.
-
Constructor Details
-
InventoryUtility
public InventoryUtility()
-
-
Method Details
-
registerEnableEnderCondition
-
registerStackExtractor
-
registerStackExtractor
public static <Inv extends IInventory> void registerStackExtractor(String key, Function<ItemStack, ? extends Inv> extractor) -
registerInventoryProvider
-
registerInventoryProvider
public static <Inv extends IInventory> void registerInventoryProvider(String key, Function<EntityPlayerMP, ? extends Inv> extractor) -
getStackExtractors
public static Iterator<? extends InventoryUtility.ItemStackExtractor> getStackExtractors(EntityPlayerMP player) -
newInventoryProvider
public static <Inv extends IInventory> InventoryUtility.InventoryProvider<InventoryIterable<Inv>> newInventoryProvider(Function<EntityPlayerMP, ? extends Inv> extractor) -
newItemStackProvider
public static InventoryUtility.ItemStackExtractor newItemStackProvider(Function<ItemStack, ? extends IInventory> extractor) -
takeFromInventory
public static Map<ItemStack, Integer> takeFromInventory(EntityPlayerMP player, Predicate<ItemStack> predicate, boolean simulate, int count) take count amount of stacks that matches given filter. might take partial amount of stuff, so simulation is suggested if you ever need to take more than one.- Parameters:
player- source of stackspredicate- item stack filtersimulate- whether to do removalcount- let's hope int size is enough...- Returns:
- amount taken. never negative nor bigger than count...
-
takeFromInventory
take count amount of stacks that matches given filter. might take partial amount of stuff, so simulation is suggested if you ever need to take more than one.- Parameters:
player- source of stacksfilter- the precise type of item to extract. stackSize matterssimulate- whether to do removal- Returns:
- amount taken. never negative nor bigger than count...
-
takeFromInventory
public static Map<ItemStack, Integer> takeFromInventory(Iterable<ItemStack> inv, Predicate<ItemStack> predicate, boolean simulate, int count, boolean recursive) take count amount of stacks that matches given filter. Will do 1 level of recursion to try find more stacks.... e.g. from backpacks...- Parameters:
inv- source of stackspredicate- item stack filtersimulate- whether to do removalcount- let's hope int size is enough...recursive- do recursive lookup usingstack extractors- Returns:
- amount taken. never negative nor bigger than count...
-
init
public static void init()
-