Package com.minecolonies.api.util
Class InventoryFunctions
java.lang.Object
com.minecolonies.api.util.InventoryFunctions
Java8 functional interfaces for inventories. Most methods will be remapping of parameters to reduce duplication. Because of erasure clashes, not
all combinations are supported.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface describing a Action that is executed ones a Match (the given ItemStack) is found in the given slot.static interfaceFunctional interface describing a Action that is executed ones a Match (the given ItemStack) is found in the given slot. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanmatchFirstInHandlerWithAction(@NotNull net.neoforged.neoforge.items.IItemHandler itemHandler, @NotNull Predicate<net.minecraft.world.item.ItemStack> tester, @NotNull InventoryFunctions.IMatchActionResultHandler action) Search for a stack in an Inventory matching the predicate.static booleanmatchFirstInProvider(IItemHandlerCapProvider inventory, @NotNull BiPredicate<Integer, net.minecraft.world.item.ItemStack> tester) Search for a stack in an Inventory matching the predicate.static booleanmatchFirstInProvider(IItemHandlerCapProvider provider, @NotNull Predicate<net.minecraft.world.item.ItemStack> tester) Search for a stack in an Inventory matching the predicate.static booleanmatchFirstInProviderWithAction(IItemHandlerCapProvider provider, @NotNull Predicate<net.minecraft.world.item.ItemStack> tester, @NotNull InventoryFunctions.IMatchActionResult action) Search for a stack in an Inventory matching the predicate.static booleanmatchFirstInProviderWithSimpleAction(IItemHandlerCapProvider provider, @NotNull Predicate<net.minecraft.world.item.ItemStack> tester, @NotNull Consumer<Integer> action) Search for a stack in an Inventory matching the predicate.
-
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 intester- 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 intester- the function to use for testing slotsaction- 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 intester- the function to use for testing slotsaction- 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 intester- the function to use for testing slotsaction- 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 intester- the function to use for testing slots- Returns:
- true if it found a stack
-