Class InventoryUtility


  • public class InventoryUtility
    extends java.lang.Object
    This class is part of API, but is not stable. Use at your own risk.
    • Constructor Detail

      • InventoryUtility

        public InventoryUtility()
    • Method Detail

      • registerEnableEnderCondition

        public static void registerEnableEnderCondition​(java.util.function.Predicate<? super EntityPlayerMP> predicate)
      • registerStackExtractor

        public static <Inv extends IInventory> void registerStackExtractor​(java.lang.String key,
                                                                           java.util.function.Function<ItemStack,​? extends Inv> extractor)
      • registerInventoryProvider

        public static <Inv extends IInventory> void registerInventoryProvider​(java.lang.String key,
                                                                              java.util.function.Function<EntityPlayerMP,​? extends Inv> 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 stacks
        predicate - item stack filter
        simulate - whether to do removal
        count - 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 stacks
        filter - the precise type of item to extract. stackSize matters
        simulate - 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 stacks
        predicate - item stack filter
        simulate - whether to do removal
        count - let's hope int size is enough...
        recursive - do recursive lookup using stack extractors
        Returns:
        amount taken. never negative nor bigger than count...