Class InventoryUtility
- java.lang.Object
-
- com.gtnewhorizon.structurelib.util.InventoryUtility
-
public class InventoryUtility extends java.lang.ObjectThis class is part of API, but is not stable. Use at your own risk.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceInventoryUtility.InventoryProvider<R extends java.lang.Iterable<ItemStack>>static interfaceInventoryUtility.ItemStackCounterstatic interfaceInventoryUtility.ItemStackExtractorstatic interfaceInventoryUtility.OptimizedExtractor
-
Constructor Summary
Constructors Constructor Description InventoryUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Iterator<? extends InventoryUtility.ItemStackExtractor>getStackExtractors(EntityPlayerMP player)static voidinit()static <Inv extends IInventory>
InventoryUtility.InventoryProvider<InventoryIterable<Inv>>newInventoryProvider(java.util.function.Function<EntityPlayerMP,? extends Inv> extractor)static InventoryUtility.ItemStackExtractornewItemStackProvider(java.util.function.Function<ItemStack,? extends IInventory> extractor)static voidregisterEnableEnderCondition(java.util.function.Predicate<? super EntityPlayerMP> predicate)static voidregisterInventoryProvider(java.lang.String key, InventoryUtility.InventoryProvider<?> val)static <Inv extends IInventory>
voidregisterInventoryProvider(java.lang.String key, java.util.function.Function<EntityPlayerMP,? extends Inv> extractor)static voidregisterStackExtractor(java.lang.String key, InventoryUtility.ItemStackExtractor val)static <Inv extends IInventory>
voidregisterStackExtractor(java.lang.String key, java.util.function.Function<ItemStack,? extends Inv> extractor)static java.util.Map<ItemStack,java.lang.Integer>takeFromInventory(java.lang.Iterable<ItemStack> inv, java.util.function.Predicate<ItemStack> predicate, boolean simulate, int count, boolean recursive)take count amount of stacks that matches given filter.static java.util.Map<ItemStack,java.lang.Integer>takeFromInventory(EntityPlayerMP player, java.util.function.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.
-
-
-
Method Detail
-
registerEnableEnderCondition
public static void registerEnableEnderCondition(java.util.function.Predicate<? super EntityPlayerMP> predicate)
-
registerStackExtractor
public static void registerStackExtractor(java.lang.String key, InventoryUtility.ItemStackExtractor val)
-
registerStackExtractor
public static <Inv extends IInventory> void registerStackExtractor(java.lang.String key, java.util.function.Function<ItemStack,? extends Inv> extractor)
-
registerInventoryProvider
public static void registerInventoryProvider(java.lang.String key, InventoryUtility.InventoryProvider<?> val)
-
registerInventoryProvider
public static <Inv extends IInventory> void registerInventoryProvider(java.lang.String key, java.util.function.Function<EntityPlayerMP,? extends Inv> extractor)
-
getStackExtractors
public static java.util.Iterator<? extends InventoryUtility.ItemStackExtractor> getStackExtractors(EntityPlayerMP player)
-
newInventoryProvider
public static <Inv extends IInventory> InventoryUtility.InventoryProvider<InventoryIterable<Inv>> newInventoryProvider(java.util.function.Function<EntityPlayerMP,? extends Inv> extractor)
-
newItemStackProvider
public static InventoryUtility.ItemStackExtractor newItemStackProvider(java.util.function.Function<ItemStack,? extends IInventory> extractor)
-
takeFromInventory
public static java.util.Map<ItemStack,java.lang.Integer> takeFromInventory(EntityPlayerMP player, java.util.function.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
public static int takeFromInventory(EntityPlayerMP player, ItemStack filter, boolean simulate)
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 java.util.Map<ItemStack,java.lang.Integer> takeFromInventory(java.lang.Iterable<ItemStack> inv, java.util.function.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()
-
-