Class RecipeList<T extends net.minecraft.world.item.crafting.Recipe<?>>

java.lang.Object
com.blamejared.crafttweaker.api.recipe.RecipeList<T>
Type Parameters:
T - The base type of Recipe in this list.

public class RecipeList<T extends net.minecraft.world.item.crafting.Recipe<?>> extends Object
This class acts as a wrapper for the (currently) two recipe maps that vanilla stores recipes in: The recipes map, which is used for actual recipe lookups. The byName map, which is used when you have a recipe id, and want to get the recipe for that id, such as in the recipe book.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RecipeList(net.minecraft.world.item.crafting.RecipeType<T> recipeType, Collection<net.minecraft.world.item.crafting.RecipeHolder<T>> recipes, Map<net.minecraft.resources.ResourceLocation,net.minecraft.world.item.crafting.RecipeHolder<?>> byName)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.crafting.RecipeHolder<T> recipe)
    Adds the given recipe to this list.
    net.minecraft.world.item.crafting.RecipeHolder<T>
    get(String id)
    Gets a recipe based on the given id.
    net.minecraft.world.item.crafting.RecipeHolder<T>
    get(net.minecraft.resources.ResourceLocation id)
    Gets a recipe based on the given id.
    Map<net.minecraft.resources.ResourceLocation,net.minecraft.world.item.crafting.RecipeHolder<T>>
    Gets an unmodifiable view of the byName map in this list.
    Collection<net.minecraft.world.item.crafting.RecipeHolder<T>>
    Gets an unmodifiable view of the recipes in this list.
    List<net.minecraft.world.item.crafting.RecipeHolder<T>>
    Gets recipes based on the output item, checked against the given IIngredient.
    List<net.minecraft.world.item.crafting.RecipeHolder<T>>
    getRecipesMatching(Predicate<net.minecraft.world.item.crafting.RecipeHolder<T>> predicate)
    Gets recipes that match the predicate.
    net.minecraft.world.item.crafting.RecipeType<T>
    Gets the recipe type that this list deals with.
    int
    Gets how many recipes are in this list.
    boolean
    has(String id)
    Checks if this list contains a recipe with the given key.
    boolean
    has(net.minecraft.resources.ResourceLocation id)
    Checks if this list contains a recipe with the given key.
    void
    remove(net.minecraft.resources.ResourceLocation id)
    Remove the recipe with the given id.
    void
    Removes all recipes in this list.
    void
    removeByIdTest(Predicate<net.minecraft.resources.ResourceLocation> idPredicate)
    Removes recipes that pass the given id Predicate.
    void
    removeByIdTest(Predicate<net.minecraft.resources.ResourceLocation> idPredicate, Predicate<String> exclusions)
    Removes recipes that pass the given id Predicate.
    void
    removeByRecipeTest(Predicate<net.minecraft.world.item.crafting.RecipeHolder<T>> recipePredicate)
    Removes recipes that pass the given recipe Predicate

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RecipeList

      public RecipeList(net.minecraft.world.item.crafting.RecipeType<T> recipeType, Collection<net.minecraft.world.item.crafting.RecipeHolder<T>> recipes, Map<net.minecraft.resources.ResourceLocation,net.minecraft.world.item.crafting.RecipeHolder<?>> byName)
  • Method Details

    • getRecipesByOutput

      public List<net.minecraft.world.item.crafting.RecipeHolder<T>> getRecipesByOutput(IIngredient output)
      Gets recipes based on the output item, checked against the given IIngredient.
      Parameters:
      output - The output of the recipes to get.
      Returns:
      A List of recipes who's output matches the given IIngredient.
    • getRecipesMatching

      public List<net.minecraft.world.item.crafting.RecipeHolder<T>> getRecipesMatching(Predicate<net.minecraft.world.item.crafting.RecipeHolder<T>> predicate)
      Gets recipes that match the predicate.
      Parameters:
      predicate - A predicate of net.minecraft.world.item.crafting.RecipeHolder<T extends net.minecraft.world.item.crafting.Recipe<?>> to test recipes against.
      Returns:
      A List of recipes that match the given predicate
    • get

      public net.minecraft.world.item.crafting.RecipeHolder<T> get(net.minecraft.resources.ResourceLocation id)
      Gets a recipe based on the given id.
      Parameters:
      id - The resource location id of the recipe.
      Returns:
      Teh found recipe or null if not found.
    • get

      public net.minecraft.world.item.crafting.RecipeHolder<T> get(String id)
      Gets a recipe based on the given id.
      Parameters:
      id - The string id of the recipe.
      Returns:
      Teh found recipe or null if not found.
    • has

      public boolean has(net.minecraft.resources.ResourceLocation id)
      Checks if this list contains a recipe with the given key.
      Parameters:
      id - The resource location id of the recipe.
      Returns:
      True if the list has the recipe, false otherwise.
    • has

      public boolean has(String id)
      Checks if this list contains a recipe with the given key.
      Parameters:
      id - The string id of the recipe.
      Returns:
      True if the list has the recipe, false otherwise.
    • add

      public void add(net.minecraft.resources.ResourceLocation id, net.minecraft.world.item.crafting.RecipeHolder<T> recipe)
      Adds the given recipe to this list.
      Parameters:
      id - The id of the recipe.
      recipe - The recipe to add.
    • remove

      public void remove(net.minecraft.resources.ResourceLocation id)
      Remove the recipe with the given id.
      Parameters:
      id - The id of the recipe to remove.
    • removeByRecipeTest

      public void removeByRecipeTest(Predicate<net.minecraft.world.item.crafting.RecipeHolder<T>> recipePredicate)
      Removes recipes that pass the given recipe Predicate
      Parameters:
      recipePredicate - The predicate to check the recipes against.
    • removeByIdTest

      public void removeByIdTest(Predicate<net.minecraft.resources.ResourceLocation> idPredicate)
      Removes recipes that pass the given id Predicate.
      Parameters:
      idPredicate - The predicate to check the recipe id against.
    • removeByIdTest

      public void removeByIdTest(Predicate<net.minecraft.resources.ResourceLocation> idPredicate, Predicate<String> exclusions)
      Removes recipes that pass the given id Predicate.
      Parameters:
      idPredicate - The predicate to check the recipe id against.
      exclusions - A predicate to exclude certain recipes from removal.
    • removeAll

      public void removeAll()
      Removes all recipes in this list.
    • getRecipeType

      public net.minecraft.world.item.crafting.RecipeType<T> getRecipeType()
      Gets the recipe type that this list deals with.
      Returns:
      The recipe type that this list deals with.
    • getRecipes

      public Collection<net.minecraft.world.item.crafting.RecipeHolder<T>> getRecipes()
      Gets an unmodifiable view of the recipes in this list.
      Returns:
      An unmodifiable view of the recipes in this list.
    • getByName

      public Map<net.minecraft.resources.ResourceLocation,net.minecraft.world.item.crafting.RecipeHolder<T>> getByName()
      Gets an unmodifiable view of the byName map in this list.
      Returns:
      An unmodifiable view of the byName map in this list.
    • getSize

      public int getSize()
      Gets how many recipes are in this list.
      Returns:
      How many recipes are in this list.