Class InventoryUtility

java.lang.Object
com.gtnewhorizon.structurelib.util.InventoryUtility

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

    • InventoryUtility

      public InventoryUtility()
  • Method Details

    • registerEnableEnderCondition

      public static void registerEnableEnderCondition(Predicate<? super EntityPlayerMP> predicate)
    • registerStackExtractor

      public static void registerStackExtractor(String key, InventoryUtility.ItemStackExtractor val)
    • registerStackExtractor

      public static <Inv extends IInventory> void registerStackExtractor(String key, Function<ItemStack,? extends Inv> extractor)
    • registerInventoryProvider

      public static void registerInventoryProvider(String key, InventoryUtility.InventoryProvider<?> val)
    • 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 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 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 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...
    • init

      public static void init()