Interface Recipe<T extends RecipeInput>

All Known Subinterfaces:
CookingRecipe, CraftingRecipe, ShapedCraftingRecipe, ShapelessCraftingRecipe, SmithingRecipe, SpecialCraftingRecipe, StoneCutterRecipe

public interface Recipe<T extends RecipeInput>
A general interface for recipes.

Currently supported recipe types are:

ShapelessCraftingRecipe for recipes with simple ingredients/result without pattern in a CraftingInventory

ShapedCraftingRecipe for recipes with simple ingredients/result in a pattern in a CraftingInventory

SpecialCraftingRecipe for recipes with complex ingredients and result in a CraftingInventory

CookingRecipe for recipes in Furnace, BlastFurnace, Smoker and Campfire

StoneCutterRecipe for recipes in a BlockTypes.STONECUTTER block

SmithingRecipe for recipes in a BlockTypes.SMITHING_TABLE block

  • Method Details

    • isValid

      boolean isValid(T inventory, ServerWorld world)
      Checks if the given inventory fits the required constraints to make a valid recipe
      Parameters:
      inventory - The inventory to check for validity
      world - The world this recipe would be used in
      Returns:
      True if the given input matches this recipe's requirements
    • result

      ItemStackSnapshot result(T inventory)
      The result of this recipe. This method should only be called if isValid(RecipeInput, ServerWorld) returns true.

      This method is preferred over the exemplaryResult() method, as it may customize the result further depending on the context.

      Parameters:
      inventory - The input inventory
      Returns:
      The result of this recipe
    • exemplaryResult

      ItemStackSnapshot exemplaryResult()
      A general result of this recipe. This result may be customized depending on the context. See result(RecipeInput)
      Returns:
      The exemplary result of this recipe
    • remainingItems

      List<ItemStackSnapshot> remainingItems(T inventory)
      The remaining items result of this recipe. This method should only be called if isValid(RecipeInput, ServerWorld) returns true.

      A list of items to be added to the inventory of the player when they craft the result. For example, if a player crafts a ItemTypes.CAKE, the empty buckets are returned to their inventory.

      Parameters:
      inventory - The input inventory
      Returns:
      The list of items to be added to the inventory of the player when the recipe has been fulfilled (possibly empty)
    • result

      default Optional<RecipeResult> result(T inventory, ServerWorld world)
      Returns the RecipeResult for the given inventory and world.

      Returns Optional.empty() if the arguments do not satisfy isValid(RecipeInput, ServerWorld).

      Parameters:
      inventory - The input inventory
      world - The world this recipe would be used in
      Returns:
      A RecipeResult if the arguments satisfy isValid(RecipeInput, ServerWorld), or Optional.empty() if not
    • ingredients

      List<Ingredient> ingredients()
      Gets the ingredients for this recipe.
      Returns:
      An unmodifiable list of the ingredients.
    • isDynamic

      boolean isDynamic()
      Returns true if the recipe is dynamic.

      Dynamic recipes are not displayed in the recipe book.

      Returns:
      Whether this recipe is dynamic.
    • type

      RecipeType<? extends Recipe<?>> type()
      Gets the RecipeType of this recipe.
      Returns:
      The recipe type.