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.minecraftforge.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(net.minecraftforge.common.capabilities.ICapabilityProvider inventory, @NotNull BiPredicate<Integer, net.minecraft.world.item.ItemStack> tester) Search for a stack in an Inventory matching the predicate.static booleanmatchFirstInProvider(net.minecraftforge.common.capabilities.ICapabilityProvider provider, @NotNull Predicate<net.minecraft.world.item.ItemStack> tester) Search for a stack in an Inventory matching the predicate.static booleanmatchFirstInProviderWithAction(net.minecraftforge.common.capabilities.ICapabilityProvider 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(net.minecraftforge.common.capabilities.ICapabilityProvider 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(net.minecraftforge.common.capabilities.ICapabilityProvider 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(net.minecraftforge.common.capabilities.ICapabilityProvider 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.minecraftforge.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(net.minecraftforge.common.capabilities.ICapabilityProvider 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(net.minecraftforge.common.capabilities.ICapabilityProvider 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
-