Class ContainerUtils
java.lang.Object
top.girlkisser.lazuli.api.inventory.ContainerUtils
Provides a handful of helpers for containers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcountItems(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> matching) Count how many items the container has that match the predicate.static booleandoesListContainItemMatchingIngredient(List<net.minecraft.world.item.ItemStack> stacks, net.minecraft.world.item.crafting.Ingredient ingredient) Check if the provided list contains at least one item that matches the ingredient.static intextractItems(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> matching, int count) Extract items from the given container.static intextractItemsForCrafting(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> matching, int count) Extract items from the given container and checks for crafting remainders on extracted items.
-
Method Details
-
extractItems
public static int extractItems(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> matching, int count) Extract items from the given container.- Parameters:
container- The container to extract items from.matching- What predicate for which items to extract.count- The maximum amount of items to extract.- Returns:
- The amount of items extracted.
-
countItems
public static int countItems(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> matching) Count how many items the container has that match the predicate.- Parameters:
container- The container to check.matching- The predicate to use.- Returns:
- The amount of matching items.
-
doesListContainItemMatchingIngredient
public static boolean doesListContainItemMatchingIngredient(List<net.minecraft.world.item.ItemStack> stacks, net.minecraft.world.item.crafting.Ingredient ingredient) Check if the provided list contains at least one item that matches the ingredient.- Parameters:
stacks- The stacks to check.ingredient- The ingredient to match.- Returns:
- Whether the list contains the ingredient.
-
extractItemsForCrafting
public static int extractItemsForCrafting(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> matching, int count) Extract items from the given container and checks for crafting remainders on extracted items.- Parameters:
container- The container to extract items from.matching- What predicate for which items to extract.count- The maximum amount of items to extract.- Returns:
- The amount of items extracted.
- See Also:
-