Class ContainerUtils

java.lang.Object
top.girlkisser.lazuli.api.inventory.ContainerUtils

public final class ContainerUtils extends Object
Provides a handful of helpers for containers.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.
    static int
    extractItems(net.minecraft.world.Container container, Predicate<net.minecraft.world.item.ItemStack> matching, int count)
    Extract items from the given container.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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: