Class RecipeMatcher

java.lang.Object
net.minecraft.recipe.RecipeMatcher

public class RecipeMatcher
extends Object
Matching class that matches a recipe to its required resources. This specifically does not check patterns (See ShapedRecipe for that).
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    (package private) class  RecipeMatcher.Filter  
  • Field Summary

    Fields
    Modifier and Type Field Description
    Int2IntMap inputs  
  • Constructor Summary

    Constructors
    Constructor Description
    RecipeMatcher()  
  • Method Summary

    Modifier and Type Method Description
    private void addInput​(int itemId, int count)
    Adds an input to be used for recipe matching.
    void addInput​(ItemStack stack)
    Adds a full item stack to the pool of available resources.
    void addUnenchantedInput​(ItemStack stack)
    Adds a full item stack to the pool of available resources.
    void clear()  
    private int consume​(int itemId, int count)
    Consumes a resource from the pool of available items.
    private boolean contains​(int itemId)
    Determines whether a raw item id is present in the pool of crafting resources.
    int countCrafts​(Recipe<?> recipe, int limit, IntList output)
    Determines the number of crafts that can be produced for a recipe using the collected resources available to this crafter.
    int countCrafts​(Recipe<?> recipe, IntList output)
    Determines the number of crafts that can be produced for a recipe using the collected resources available to this crafter.
    static int getItemId​(ItemStack stack)  
    static ItemStack getStackFromId​(int itemId)  
    boolean match​(Recipe<?> recipe, IntList output)
    Attempts to match the recipe against the collected inputs.
    boolean match​(Recipe<?> recipe, IntList output, int multiplier)
    Attempts to match the recipe against the collected inputs.
    void method_20478​(ItemStack itemStack, int int2)  

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • RecipeMatcher

      public RecipeMatcher()
  • Method Details

    • addUnenchantedInput

      public void addUnenchantedInput​(ItemStack stack)
      Adds a full item stack to the pool of available resources.

      This is equivalent to calling addInput(stack, Item.DEFAULT_MAX_COUNT).

    • addInput

      public void addInput​(ItemStack stack)
      Adds a full item stack to the pool of available resources.

      This is equivalent to calling addInput(stack, Item.DEFAULT_MAX_COUNT).

    • method_20478

      public void method_20478​(ItemStack itemStack, int int2)
    • getItemId

      public static int getItemId​(ItemStack stack)
    • contains

      private boolean contains​(int itemId)
      Determines whether a raw item id is present in the pool of crafting resources.
    • consume

      private int consume​(int itemId, int count)
      Consumes a resource from the pool of available items.
      Parameters:
      itemId - the raw id of the item being consumed
      count - the number of times that item must be consumed
    • addInput

      private void addInput​(int itemId, int count)
      Adds an input to be used for recipe matching.
      Parameters:
      itemId - the raw ID of the item to match
      count - the item's count
    • match

      public boolean match​(Recipe<?> recipe, @Nullable IntList output)
      Attempts to match the recipe against the collected inputs. Assumes only one output is required.
      Parameters:
      recipe - the recipe to match against
      output - optional output list of item ids that were matched whilst evaluating the recipe conditions
    • match

      public boolean match​(Recipe<?> recipe, @Nullable IntList output, int multiplier)
      Attempts to match the recipe against the collected inputs. Will only succeed if there has been enough resources gathered to produce the requested number of outputs.
      Parameters:
      recipe - the recipe to match against
      output - optional output list of item ids that were matched whilst evaluating the recipe conditions
      multiplier - the number of expected outputs
    • countCrafts

      public int countCrafts​(Recipe<?> recipe, @Nullable IntList output)
      Determines the number of crafts that can be produced for a recipe using the collected resources available to this crafter.
      Parameters:
      recipe - the recipe to match against
      output - optional output list of item ids that were matched whilst evaluating the recipe conditions
    • countCrafts

      public int countCrafts​(Recipe<?> recipe, int limit, @Nullable IntList output)
      Determines the number of crafts that can be produced for a recipe using the collected resources available to this crafter.
      Parameters:
      recipe - the recipe to match against
      output - optional output list of item ids that were matched whilst evaluating the recipe conditions
    • getStackFromId

      public static ItemStack getStackFromId​(int itemId)
    • clear

      public void clear()