Class InventoryFunctions

java.lang.Object
com.minecolonies.api.util.InventoryFunctions

public final class InventoryFunctions extends Object
Java8 functional interfaces for inventories. Most methods will be remapping of parameters to reduce duplication. Because of erasure clashes, not all combinations are supported.
  • Method Details

    • matchFirstInProvider

      public static boolean matchFirstInProvider(IItemHandlerCapProvider provider, @NotNull @NotNull Predicate<net.minecraft.world.item.ItemStack> tester)
      Search for a stack in an Inventory matching the predicate.
      Parameters:
      provider - the provider to search in
      tester - the function to use for testing slots
      Returns:
      true if it found a stack
    • matchFirstInProviderWithAction

      public static boolean matchFirstInProviderWithAction(IItemHandlerCapProvider provider, @NotNull @NotNull Predicate<net.minecraft.world.item.ItemStack> tester, @NotNull @NotNull InventoryFunctions.IMatchActionResult action)
      Search for a stack in an Inventory matching the predicate.
      Parameters:
      provider - the provider to search in
      tester - the function to use for testing slots
      action - the function to use if a slot matches
      Returns:
      true if it found a stack
    • matchFirstInHandlerWithAction

      public static boolean matchFirstInHandlerWithAction(@NotNull @NotNull net.neoforged.neoforge.items.IItemHandler itemHandler, @NotNull @NotNull Predicate<net.minecraft.world.item.ItemStack> tester, @NotNull @NotNull InventoryFunctions.IMatchActionResultHandler action)
      Search for a stack in an Inventory matching the predicate.
      Parameters:
      itemHandler - the handler to search in
      tester - the function to use for testing slots
      action - the function to use if a slot matches
      Returns:
      true if it found a stack
    • matchFirstInProviderWithSimpleAction

      public static boolean matchFirstInProviderWithSimpleAction(IItemHandlerCapProvider provider, @NotNull @NotNull Predicate<net.minecraft.world.item.ItemStack> tester, @NotNull @NotNull Consumer<Integer> action)
      Search for a stack in an Inventory matching the predicate.
      Parameters:
      provider - the provider to search in
      tester - the function to use for testing slots
      action - the function to use if a slot matches
      Returns:
      true if it found a stack
    • matchFirstInProvider

      public static boolean matchFirstInProvider(IItemHandlerCapProvider inventory, @NotNull @NotNull BiPredicate<Integer,net.minecraft.world.item.ItemStack> tester)
      Search for a stack in an Inventory matching the predicate. (IInventory, Integer) -> Boolean
      Parameters:
      inventory - the inventory to search in
      tester - the function to use for testing slots
      Returns:
      true if it found a stack