tModLoader v2024.11
A mod to make and play Terraria mods
|
A Recipe is a collection of ingredients, tiles, and a resulting Item. This is how players can craft items in the game.
The Basic Recipes Guideteaches how to add new recipes to the game and how to manipulate existing recipes.
Use Recipe.Create(int, int) to create a Recipe instance resulting in the specified item. Use AddIngredient(int, int) to add ingredients and AddTile(int) to add crafting stations. Finally, use Register to complete the recipe and register it to the game.
Recipes can only be added in ModSystem.AddRecipes, ModItem.AddRecipes, and GlobalItem.AddRecipes.
Recipes should be edited only in ModSystem.PostAddRecipes.
More...
Classes | |
class | ConsumptionRules |
Public Member Functions | |
bool | AcceptedByItemGroups (int invType, int reqType) |
bool | AcceptsGroup (int groupId) |
Recipe | AddCondition (Condition condition) |
Recipe | AddCondition (IEnumerable< Condition > conditions) |
Adds a collection of conditions that will determine whether or not the recipe will be to be available for the player to use. The conditions can be unrelated to items or tiles (for example, biome or time). More... | |
Recipe | AddCondition (LocalizedText description, Func< bool > condition) |
Sets a condition delegate that will determine whether or not the recipe will be to be available for the player to use. The condition can be unrelated to items or tiles (for example, biome or time). More... | |
Recipe | AddCondition (params Condition[] conditions) |
Adds an array of conditions that will determine whether or not the recipe will be to be available for the player to use. The conditions can be unrelated to items or tiles (for example, biome or time). More... | |
Recipe | AddConsumeItemCallback (ConsumeItemCallback callback) |
Sets a callback that allows you to determine how many of a certain ingredient is consumed when this recipe is used. Return the number of ingredients that will actually be consumed. By default returns numRequired. | |
Recipe | AddCustomShimmerResult (int itemType, int itemStack=1) |
Recipe | AddDecraftCondition (Condition condition) |
Recipe | AddDecraftCondition (IEnumerable< Condition > conditions) |
Adds a collection of conditions that will determine whether or not the recipe can be shimmered/decrafted. The conditions can be unrelated to items or tiles (for example, biome or time). More... | |
Recipe | AddDecraftCondition (LocalizedText description, Func< bool > condition) |
Sets a condition delegate that will determine whether or not the recipe can be shimmered/decrafted. The condition can be unrelated to items or tiles (for example, biome or time). More... | |
Recipe | AddDecraftCondition (params Condition[] conditions) |
Adds an array of conditions that will determine whether or not the recipe can be shimmered/decrafted. The conditions can be unrelated to items or tiles (for example, biome or time). More... | |
Recipe | AddIngredient (int itemID, int stack=1) |
Adds an ingredient to this recipe with the given item type and stack size. Ex: recipe.AddIngredient(ItemID.IronAxe) More... | |
Recipe | AddIngredient (Mod mod, string itemName, int stack=1) |
Adds an ingredient to this recipe with the given item name from the given mod, and with the given stack stack. If the mod parameter is null, then it will automatically use an item from the mod creating this recipe. More... | |
Recipe | AddIngredient (ModItem item, int stack=1) |
Adds an ingredient to this recipe of the given type of item and stack size. More... | |
Recipe | AddIngredient< T > (int stack=1) |
Adds an ingredient to this recipe of the given type of item and stack size. More... | |
Recipe | AddOnCraftCallback (OnCraftCallback callback) |
Sets a callback that will allow you to make anything happen when the recipe is used to create an item. | |
Recipe | AddRecipeGroup (int recipeGroupId, int stack=1) |
Adds a recipe group ingredient to this recipe with the given RecipeGroupID and stack size. Recipe groups allow a recipe to use alternate ingredients without making multiple recipes. For example the RecipeGroupID.IronBar group accepts either ItemID.IronBar or ItemID.LeadBar. The Recipe Groups wiki guidehas more information. Vanilla recipe group IDs can be found in RecipeGroupID and modded recipe group IDs will be returned from RecipeGroup.RegisterGroup(string, RecipeGroup). AddRecipeGroup(string, int) can be used instead if the ID number is not known but the name is known. More... | |
Recipe | AddRecipeGroup (RecipeGroup recipeGroup, int stack=1) |
Adds a recipe group ingredient to this recipe with the given RecipeGroup. More... | |
Recipe | AddRecipeGroup (string name, int stack=1) |
Adds a recipe group ingredient to this recipe with the given RecipeGroup name and stack size. Recipe groups allow a recipe to use alternate ingredients without making multiple recipes. For example the "IronBar" group accepts either ItemID.IronBar or ItemID.LeadBar. The Recipe Groups wiki guidehas more information. To use a vanilla recipe group, use AddRecipeGroup(int, int) using a RecipeGroupID entry instead. More... | |
Recipe | AddTile (int tileID) |
Adds a required crafting station with the given tile type to this recipe. Ex: recipe.AddTile(TileID.WorkBenches) More... | |
Recipe | AddTile (Mod mod, string tileName) |
Adds a required crafting station to this recipe with the given tile name from the given mod. If the mod parameter is null, then it will automatically use a tile from the mod creating this recipe. More... | |
Recipe | AddTile (ModTile tile) |
Adds a required crafting station to this recipe of the given type of tile. More... | |
Recipe | AddTile< T > () |
Adds a required crafting station to this recipe of the given type of tile. More... | |
Recipe | ApplyConditionsAsDecraftConditions () |
Adds every condition from Recipe.Conditions to Recipe.DecraftConditions, checking for duplicates. | |
Recipe | Clone () |
Returns a clone of this recipe except the source mod of the Recipe will the currently loading mod. The clone will have to be registered after being tweaked. | |
delegate void | ConsumeItemCallback (Recipe recipe, int type, ref int amount) |
bool | ContainsIngredient (int itemType) |
void | Create () |
Recipe | DisableDecraft () |
Sets a check that is used during load to prevent this being shimmered/decrafted. More... | |
void | DisableRecipe () |
bool | HasCondition (Condition condition) |
bool | HasIngredient (int itemID) |
bool | HasIngredient (Mod mod, string itemName) |
bool | HasIngredient (ModItem item) |
bool | HasIngredient< T > () |
bool | HasRecipeGroup (int id) |
bool | HasRecipeGroup (RecipeGroup group) |
bool | HasRecipeGroup (string name) |
bool | HasResult (int itemID) |
bool | HasResult (Mod mod, string itemName) |
bool | HasResult (ModItem item) |
bool | HasResult< T > () |
bool | HasShimmerCondition (Condition condition) |
bool | HasTile (int tileID) |
bool | HasTile (Mod mod, string tileName) |
bool | HasTile (ModTile tile) |
bool | HasTile< T > () |
delegate void | OnCraftCallback (Recipe recipe, Item item, List< Item > consumedItems, Item destinationStack) |
bool | ProcessGroupsForText (int type, out string theText) |
Recipe | Register () |
Adds this recipe to the game. Call this after you have finished setting the result, ingredients, etc. More... | |
bool | RemoveCondition (Condition condition) |
bool | RemoveIngredient (int itemID) |
bool | RemoveIngredient (Item item) |
bool | RemoveRecipeGroup (int groupID) |
bool | RemoveShimmerCondition (Condition condition) |
bool | RemoveTile (int tileID) |
void | ReplaceResult (int itemID, int stack=1) |
void | ReplaceResult (Mod mod, string itemName, int stack=1) |
void | ReplaceResult (ModItem item, int stack=1) |
void | ReplaceResult< T > (int stack=1) |
void | RequireGroup (int id) |
Recipe | SortAfter (Recipe recipe) |
Sorts the recipe after the one given as parameter. Both recipes must already be registered. | |
Recipe | SortAfterFirstRecipesOf (int itemId) |
Sorts the recipe after the first one creating the item of the ID given as parameter. | |
Recipe | SortBefore (Recipe recipe) |
Sorts the recipe before the one given as parameter. Both recipes must already be registered. | |
Recipe | SortBeforeFirstRecipesOf (int itemId) |
Sorts the recipe before the first one creating the item of the ID given as parameter. | |
bool | TryGetIngredient (int itemID, out Item ingredient) |
bool | TryGetIngredient (Mod mod, string itemName, out Item ingredient) |
bool | TryGetIngredient (ModItem item, out Item ingredient) |
bool | TryGetIngredient< T > (out Item ingredient) |
bool | TryGetResult (int itemID, out Item result) |
bool | TryGetResult (Mod mod, string itemName, out Item result) |
bool | TryGetResult (ModItem item, out Item result) |
bool | TryGetResult< T > (out Item result) |
Static Public Member Functions | |
static void | ClearAvailableRecipes () |
static bool | CollectedEnoughItemsToCraftRecipeNew (Recipe tempRec) |
static bool | CollectedEnoughItemsToCraftRecipeOld (Recipe tempRec) |
static Recipe | Create (int result, int amount=1) |
Creates a recipe resulting in the given item and amount but does not yet register it into the game. Call this at the very beginning when creating a new craft. More... | |
static void | FindRecipes (bool canDelayCheck=false) |
static int | GetRequiredTileStyle (int tileID) |
static void | GetThroughDelayedFindRecipes () |
static void | SetupRecipeGroups () |
static void | SetupRecipes () |
static void | UpdateItemVariants () |
static void | UpdateWhichItemsAreCrafted () |
static void | UpdateWhichItemsAreMaterials () |
Public Attributes | |
List< int > | acceptedGroups = new() |
readonly List< Condition > | Conditions = new List<Condition>() |
Item | createItem = new Item() |
List< Item > | customShimmerResults |
readonly List< Condition > | DecraftConditions = new List<Condition>() |
readonly Mod | Mod |
List< Item > | requiredItem = new() |
List< int > | requiredTile = new() |
Recipe | target |
Static Public Attributes | |
static int | maxRecipes = 3000 |
static int | numRecipes |
Properties | |
bool | Disabled [get] |
Any recipe with this flag won't be shown in game. | |
Recipe bool after | Ordering [get, set] |
int | RecipeIndex [get, set] |
The index of the recipe in the Main.recipe array. | |
A Recipe is a collection of ingredients, tiles, and a resulting Item. This is how players can craft items in the game.
The Basic Recipes Guide
teaches how to add new recipes to the game and how to manipulate existing recipes.
Use Recipe.Create(int, int) to create a Recipe instance resulting in the specified item. Use AddIngredient(int, int) to add ingredients and AddTile(int) to add crafting stations. Finally, use Register to complete the recipe and register it to the game.
Recipes can only be added in ModSystem.AddRecipes, ModItem.AddRecipes, and GlobalItem.AddRecipes.
Recipes should be edited only in ModSystem.PostAddRecipes.
Recipe Recipe.AddCondition | ( | IEnumerable< Condition > | conditions | ) |
Adds a collection of conditions that will determine whether or not the recipe will be to be available for the player to use. The conditions can be unrelated to items or tiles (for example, biome or time).
conditions | A collection of conditions. |
Recipe Recipe.AddCondition | ( | LocalizedText | description, |
Func< bool > | condition | ||
) |
Sets a condition delegate that will determine whether or not the recipe will be to be available for the player to use. The condition can be unrelated to items or tiles (for example, biome or time).
description | A description of this condition. |
condition | A function returning whether the condition is met. |
Recipe Recipe.AddCondition | ( | params Condition[] | conditions | ) |
Adds an array of conditions that will determine whether or not the recipe will be to be available for the player to use. The conditions can be unrelated to items or tiles (for example, biome or time).
conditions | An array of conditions. |
Recipe Recipe.AddDecraftCondition | ( | IEnumerable< Condition > | conditions | ) |
Adds a collection of conditions that will determine whether or not the recipe can be shimmered/decrafted. The conditions can be unrelated to items or tiles (for example, biome or time).
conditions | A collection of conditions. |
Recipe Recipe.AddDecraftCondition | ( | LocalizedText | description, |
Func< bool > | condition | ||
) |
Sets a condition delegate that will determine whether or not the recipe can be shimmered/decrafted. The condition can be unrelated to items or tiles (for example, biome or time).
description | A description of this condition. |
condition | The predicate delegate condition. |
Recipe Recipe.AddDecraftCondition | ( | params Condition[] | conditions | ) |
Adds an array of conditions that will determine whether or not the recipe can be shimmered/decrafted. The conditions can be unrelated to items or tiles (for example, biome or time).
conditions | An array of conditions. |
Recipe Recipe.AddIngredient | ( | int | itemID, |
int | stack = 1 |
||
) |
Adds an ingredient to this recipe with the given item type and stack size. Ex: recipe.AddIngredient(ItemID.IronAxe)
itemID | The item identifier. |
stack | The stack. |
Adds an ingredient to this recipe with the given item name from the given mod, and with the given stack stack. If the mod parameter is null, then it will automatically use an item from the mod creating this recipe.
mod | The mod. |
itemName | Name of the item. |
stack | The stack. |
RecipeException | The item " + itemName + " does not exist in mod " + mod.Name + ". If you are trying to use a vanilla item, try removing the first argument. |
Adds an ingredient to this recipe of the given type of item and stack size.
item | The item. |
stack | The stack. |
Recipe Recipe.AddIngredient< T > | ( | int | stack = 1 | ) |
Adds an ingredient to this recipe of the given type of item and stack size.
stack | The stack. |
T | : | ModItem | |
T | : | AddIngredient | |
T | : | ModContent.ItemType<T>() | |
T | : | stack |
Recipe Recipe.AddRecipeGroup | ( | int | recipeGroupId, |
int | stack = 1 |
||
) |
Adds a recipe group ingredient to this recipe with the given RecipeGroupID and stack size.
Recipe groups allow a recipe to use alternate ingredients without making multiple recipes. For example the RecipeGroupID.IronBar group accepts either ItemID.IronBar or ItemID.LeadBar. The Recipe Groups wiki guidehas more information.
Vanilla recipe group IDs can be found in RecipeGroupID and modded recipe group IDs will be returned from RecipeGroup.RegisterGroup(string, RecipeGroup). AddRecipeGroup(string, int) can be used instead if the ID number is not known but the name is known.
recipeGroupId | The RecipeGroupID. |
stack | The stack. |
RecipeException | A recipe group with the ID " + recipeGroupID + " does not exist. |
Recipe Recipe.AddRecipeGroup | ( | RecipeGroup | recipeGroup, |
int | stack = 1 |
||
) |
Adds a recipe group ingredient to this recipe with the given RecipeGroup.
recipeGroup | The RecipeGroup. |
stack |
Recipe Recipe.AddRecipeGroup | ( | string | name, |
int | stack = 1 |
||
) |
Adds a recipe group ingredient to this recipe with the given RecipeGroup name and stack size.
Recipe groups allow a recipe to use alternate ingredients without making multiple recipes. For example the "IronBar" group accepts either ItemID.IronBar or ItemID.LeadBar. The Recipe Groups wiki guidehas more information.
To use a vanilla recipe group, use AddRecipeGroup(int, int) using a RecipeGroupID entry instead.
name | The name. |
stack | The stack. |
RecipeException | A recipe group with the name " + name + " does not exist. |
Recipe Recipe.AddTile | ( | int | tileID | ) |
Adds a required crafting station with the given tile type to this recipe. Ex: recipe.AddTile(TileID.WorkBenches)
tileID | The tile identifier. |
RecipeException | No tile has ID " + tileID |
Adds a required crafting station to this recipe with the given tile name from the given mod. If the mod parameter is null, then it will automatically use a tile from the mod creating this recipe.
mod | The mod. |
tileName | Name of the tile. |
RecipeException | The tile " + tileName + " does not exist in mod " + mod.Name + ". If you are trying to use a vanilla tile, try using Recipe.AddTile(tileID). |
Adds a required crafting station to this recipe of the given type of tile.
tile | The tile. |
Recipe Recipe.AddTile< T > | ( | ) |
Adds a required crafting station to this recipe of the given type of tile.
T | : | ModTile | |
T | : | AddTile | |
T | : | ModContent.TileType<T>() |
|
static |
Creates a recipe resulting in the given item and amount but does not yet register it into the game. Call this at the very beginning when creating a new craft.
result | What item will be given when the craft has been completed |
amount | The stack -> how many result items given when the recipe is crafted. (eg. 1 wood -> 4 wood platform) |
RecipeException | A Recipe can only be created inside recipe related methods |
Recipe Recipe.DisableDecraft | ( | ) |
Sets a check that is used during load to prevent this being shimmered/decrafted.
RecipeException | A Recipe can only be disabled inside Recipe related methods. |
bool Recipe.HasIngredient< T > | ( | ) |
T | : | ModItem | |
T | : | HasIngredient | |
T | : | ModContent.ItemType<T>() |
bool Recipe.HasResult< T > | ( | ) |
T | : | ModItem | |
T | : | HasResult | |
T | : | ModContent.ItemType<T>() |
bool Recipe.HasTile< T > | ( | ) |
T | : | ModTile | |
T | : | HasTile | |
T | : | ModContent.TileType<T>() |
Recipe Recipe.Register | ( | ) |
Adds this recipe to the game. Call this after you have finished setting the result, ingredients, etc.
RecipeException | A recipe without any result has been added. |
void Recipe.ReplaceResult< T > | ( | int | stack = 1 | ) |
T | : | ModItem | |
T | : | ReplaceResult | |
T | : | ModContent.ItemType<T>() | |
T | : | stack |
bool Recipe.TryGetIngredient< T > | ( | out Item | ingredient | ) |
T | : | ModItem | |
T | : | TryGetIngredient | |
T | : | ModContent.ItemType<T>() | |
T | : | out | |
T | : | ingredient |