Interface Recipe
- All Superinterfaces:
Keyed
,ResourceKeyed
- All Known Subinterfaces:
CookingRecipe
,CraftingRecipe
,ShapedCraftingRecipe
,ShapelessCraftingRecipe
,SmithingRecipe
,SpecialCraftingRecipe
,StoneCutterRecipe
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 Summary
Modifier and TypeMethodDescriptionA general result of this recipe.Gets the ingredients for this recipe.boolean
Returns true if the recipe is dynamic.boolean
isValid
(Inventory inventory, ServerWorld world) Checks if the given inventory fits the required constraints to make a valid reciperemainingItems
(Inventory inventory) The remaining items result of this recipe.The result of this recipe.default Optional<RecipeResult>
result
(Inventory inventory, ServerWorld world) Returns theRecipeResult
for the given inventory and world.RecipeType<? extends Recipe>
type()
Gets theRecipeType
of this recipe.Methods inherited from interface org.spongepowered.api.ResourceKeyed
key
-
Method Details
-
isValid
Checks if the given inventory fits the required constraints to make a valid recipe- Parameters:
inventory
- The inventory to check for validityworld
- The world this recipe would be used in- Returns:
- True if the given input matches this recipe's requirements
-
result
The result of this recipe. This method should only be called ifisValid(Inventory, ServerWorld)
returnstrue
.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. Seeresult(Inventory)
- Returns:
- The exemplary result of this recipe
-
remainingItems
The remaining items result of this recipe. This method should only be called ifisValid(Inventory, ServerWorld)
returnstrue
.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
Returns theRecipeResult
for the given inventory and world.Returns
Optional.empty()
if the arguments do not satisfyisValid(Inventory, ServerWorld)
.- Parameters:
inventory
- The input inventoryworld
- The world this recipe would be used in- Returns:
- A
RecipeResult
if the arguments satisfyisValid(Inventory, ServerWorld)
, orOptional.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 theRecipeType
of this recipe.- Returns:
- The recipe type.
-