Interface RecipeManager
-
public interface RecipeManager
Manages registered recipes. Register new Recipes duringRegisterDataPackValueEvent
usingRecipeRegistration
s. To disable a recipe override it with an empty result.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Collection<Recipe>
all()
Gets all registered recipes.default <T extends Recipe>
java.util.Collection<T>allOfType(java.util.function.Supplier<? extends RecipeType<T>> supplier)
Returns all registered recipes of given type<T extends Recipe>
java.util.Collection<T>allOfType(RecipeType<T> type)
Returns all registered recipes of given typejava.util.Optional<Recipe>
byKey(ResourceKey key)
Gets a recipe by itskey
.default <T extends Recipe>
java.util.Collection<T>findByResult(java.util.function.Supplier<? extends RecipeType<T>> supplier, ItemStackSnapshot result)
Gets all recipes with given item as a result.<T extends Recipe>
java.util.Collection<T>findByResult(RecipeType<T> type, ItemStackSnapshot result)
Returns all registered recipes of given type and with given item as a result.default <T extends CookingRecipe>
java.util.Optional<T>findCookingRecipe(java.util.function.Supplier<? extends RecipeType<T>> supplier, ItemStackSnapshot ingredient)
Finds a matching cooking recipe for given type and ingredient<T extends CookingRecipe>
java.util.Optional<T>findCookingRecipe(RecipeType<T> type, ItemStackSnapshot ingredient)
Finds a matching cooking recipe for given type and ingredientdefault <T extends Recipe>
java.util.Optional<T>findMatchingRecipe(java.util.function.Supplier<? extends RecipeType<T>> supplier, Inventory inventory, ServerWorld world)
Finds a matching recipe for given type, inventory and worldjava.util.Optional<Recipe>
findMatchingRecipe(Inventory inventory, ServerWorld world)
Finds a matching recipe for given inventory and world.<T extends Recipe>
java.util.Optional<T>findMatchingRecipe(RecipeType<T> type, Inventory inventory, ServerWorld world)
Finds a matching recipe for given type, inventory and worlddefault java.util.Optional<RecipeResult>
result(Inventory inventory, ServerWorld world)
Finds the matching recipe and creates theRecipeResult
, which is then returned.
-
-
-
Method Detail
-
byKey
java.util.Optional<Recipe> byKey(ResourceKey key)
Gets a recipe by itskey
.- Parameters:
key
- the recipe key- Returns:
- The recipe if available
-
all
java.util.Collection<Recipe> all()
Gets all registered recipes.- Returns:
- All registered recipes.
-
allOfType
<T extends Recipe> java.util.Collection<T> allOfType(RecipeType<T> type)
Returns all registered recipes of given type- Parameters:
type
- The recipe type- Returns:
- All recipes of given type
-
allOfType
default <T extends Recipe> java.util.Collection<T> allOfType(java.util.function.Supplier<? extends RecipeType<T>> supplier)
Returns all registered recipes of given type- Parameters:
supplier
- The recipe type- Returns:
- All recipes of given type
-
findByResult
<T extends Recipe> java.util.Collection<T> findByResult(RecipeType<T> type, ItemStackSnapshot result)
Returns all registered recipes of given type and with given item as a result.- Parameters:
type
- The recipe typeresult
- The recipe result to match- Returns:
- The recipes resulting in given item.
-
findByResult
default <T extends Recipe> java.util.Collection<T> findByResult(java.util.function.Supplier<? extends RecipeType<T>> supplier, ItemStackSnapshot result)
Gets all recipes with given item as a result.- Parameters:
result
- the recipe result to match- Returns:
- All recipes resulting in given item.
-
findMatchingRecipe
java.util.Optional<Recipe> findMatchingRecipe(Inventory inventory, ServerWorld world)
Finds a matching recipe for given inventory and world.- Parameters:
inventory
- The input inventoryworld
- The world- Returns:
- The found
Recipe
, orOptional.empty()
if no recipe was found for this configuration
-
findMatchingRecipe
<T extends Recipe> java.util.Optional<T> findMatchingRecipe(RecipeType<T> type, Inventory inventory, ServerWorld world)
Finds a matching recipe for given type, inventory and world- Parameters:
type
- The recipe typeinventory
- The input inventoryworld
- The world- Returns:
- The matching recipes.
-
findMatchingRecipe
default <T extends Recipe> java.util.Optional<T> findMatchingRecipe(java.util.function.Supplier<? extends RecipeType<T>> supplier, Inventory inventory, ServerWorld world)
Finds a matching recipe for given type, inventory and world- Parameters:
supplier
- The recipe typeinventory
- The input inventoryworld
- The world- Returns:
- The matching recipes.
-
findCookingRecipe
<T extends CookingRecipe> java.util.Optional<T> findCookingRecipe(RecipeType<T> type, ItemStackSnapshot ingredient)
Finds a matching cooking recipe for given type and ingredient- Parameters:
type
- The recipe typeingredient
- The ingredient- Returns:
- The matching recipe.
-
findCookingRecipe
default <T extends CookingRecipe> java.util.Optional<T> findCookingRecipe(java.util.function.Supplier<? extends RecipeType<T>> supplier, ItemStackSnapshot ingredient)
Finds a matching cooking recipe for given type and ingredient- Parameters:
supplier
- The recipe typeingredient
- The ingredient- Returns:
- The matching recipe.
-
result
default java.util.Optional<RecipeResult> result(Inventory inventory, ServerWorld world)
Finds the matching recipe and creates theRecipeResult
, which is then returned.- Parameters:
inventory
- The crafting gridworld
- The world- Returns:
- The
RecipeResult
if a recipe was found, orOptional.empty()
if not
-
-