tModLoader v2022.09
A mod to make and play Terraria mods
Terraria.Recipe Class Reference

Classes

class  Condition
 
class  ConsumptionRules
 
interface  ICondition
 

Public Member Functions

bool AcceptedByItemGroups (int invType, int reqType)
 
Recipe AddCondition (Condition condition)
 
Recipe AddCondition (IEnumerable< Condition > conditions)
 Adds a collectiom 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 (NetworkText description, Predicate< Recipe > 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 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. Vanilla recipe group IDs can be found in Terraria.ID.RecipeGroupID and modded recipe group IDs will be returned from RecipeGroup.RegisterGroup. 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. Vanilla recipe groups consist of "Wood", "IronBar", "PresurePlate", "Sand", and "Fragment". 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 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)
 
void Create ()
 
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 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)
 
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 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)
 
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 Recipe Create (int result, int amount=1)
 
static void FindRecipes (bool canDelayCheck=false)
 
static int GetRequiredTileStyle (int tileID)
 
static void GetThroughDelayedFindRecipes ()
 
static void SetupRecipeGroups ()
 
static void SetupRecipes ()
 
static void UpdateWhichItemsAreMaterials ()
 

Public Attributes

List< int > acceptedGroups = new List<int>()
 
readonly List< ConditionConditions = new List<Condition>()
 
Item createItem = new Item()
 
readonly Mod Mod
 
List< ItemrequiredItem = new List<Item>()
 
List< int > requiredTile = new List<int>()
 
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.
 

Member Function Documentation

◆ AddCondition() [1/3]

Recipe Terraria.Recipe.AddCondition ( IEnumerable< Condition conditions)

Adds a collectiom 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).

Parameters
conditionsA collection of conditions.

◆ AddCondition() [2/3]

Recipe Terraria.Recipe.AddCondition ( NetworkText  description,
Predicate< Recipe 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).

Parameters
conditionThe predicate delegate condition.
descriptionA description of this condition. Use NetworkText.FromKey, or NetworkText.FromLiteral for this.

◆ AddCondition() [3/3]

Recipe Terraria.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).

Parameters
conditionsAn array of conditions.

◆ AddIngredient() [1/3]

Recipe Terraria.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)

Parameters
itemIDThe item identifier.
stackThe stack.

◆ AddIngredient() [2/3]

Recipe Terraria.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.

Parameters
modThe mod.
itemNameName of the item.
stackThe stack.
Exceptions
RecipeExceptionThe item " + itemName + " does not exist in mod " + mod.Name + ". If you are trying to use a vanilla item, try removing the first argument.

◆ AddIngredient() [3/3]

Recipe Terraria.Recipe.AddIngredient ( ModItem  item,
int  stack = 1 
)

Adds an ingredient to this recipe of the given type of item and stack size.

Parameters
itemThe item.
stackThe stack.

◆ AddIngredient< T >()

Recipe Terraria.Recipe.AddIngredient< T > ( int  stack = 1)

Adds an ingredient to this recipe of the given type of item and stack size.

Parameters
stackThe stack.
Type Constraints
T :ModItem 
T :AddIngredient 
T :ModContent.ItemType<T>() 
T :stack 

◆ AddRecipeGroup() [1/3]

Recipe Terraria.Recipe.AddRecipeGroup ( int  recipeGroupId,
int  stack = 1 
)

Adds a recipe group ingredient to this recipe with the given RecipeGroupID and stack size. Vanilla recipe group IDs can be found in Terraria.ID.RecipeGroupID and modded recipe group IDs will be returned from RecipeGroup.RegisterGroup.

Parameters
recipeGroupIdThe RecipeGroupID.
stackThe stack.
Exceptions
RecipeExceptionA recipe group with the ID " + recipeGroupID + " does not exist.

◆ AddRecipeGroup() [2/3]

Recipe Terraria.Recipe.AddRecipeGroup ( RecipeGroup  recipeGroup,
int  stack = 1 
)

Adds a recipe group ingredient to this recipe with the given RecipeGroup.

Parameters
recipeGroupThe RecipeGroup.
stack

◆ AddRecipeGroup() [3/3]

Recipe Terraria.Recipe.AddRecipeGroup ( string  name,
int  stack = 1 
)

Adds a recipe group ingredient to this recipe with the given RecipeGroup name and stack size. Vanilla recipe groups consist of "Wood", "IronBar", "PresurePlate", "Sand", and "Fragment".

Parameters
nameThe name.
stackThe stack.
Exceptions
RecipeExceptionA recipe group with the name " + name + " does not exist.

◆ AddTile() [1/3]

Recipe Terraria.Recipe.AddTile ( int  tileID)

Adds a required crafting station with the given tile type to this recipe. Ex: recipe.AddTile(TileID.WorkBenches)

Parameters
tileIDThe tile identifier.
Exceptions
RecipeExceptionNo tile has ID " + tileID

◆ AddTile() [2/3]

Recipe Terraria.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.

Parameters
modThe mod.
tileNameName of the tile.
Exceptions
RecipeExceptionThe tile " + tileName + " does not exist in mod " + mod.Name + ". If you are trying to use a vanilla tile, try using Recipe.AddTile(tileID).

◆ AddTile() [3/3]

Recipe Terraria.Recipe.AddTile ( ModTile  tile)

Adds a required crafting station to this recipe of the given type of tile.

Parameters
tileThe tile.

◆ AddTile< T >()

Adds a required crafting station to this recipe of the given type of tile.

Type Constraints
T :ModTile 
T :AddTile 
T :ModContent.TileType<T>() 

◆ HasIngredient< T >()

bool Terraria.Recipe.HasIngredient< T > ( )
Type Constraints
T :ModItem 
T :HasIngredient 
T :ModContent.ItemType<T>() 

◆ HasResult< T >()

bool Terraria.Recipe.HasResult< T > ( )
Type Constraints
T :ModItem 
T :HasResult 
T :ModContent.ItemType<T>() 

◆ HasTile< T >()

bool Terraria.Recipe.HasTile< T > ( )
Type Constraints
T :ModTile 
T :HasTile 
T :ModContent.TileType<T>() 

◆ Register()

Recipe Terraria.Recipe.Register ( )

Adds this recipe to the game. Call this after you have finished setting the result, ingredients, etc.

Exceptions
RecipeExceptionA recipe without any result has been added.

◆ ReplaceResult< T >()

void Terraria.Recipe.ReplaceResult< T > ( int  stack = 1)
Type Constraints
T :ModItem 
T :ReplaceResult 
T :ModContent.ItemType<T>() 
T :stack 

◆ TryGetIngredient< T >()

bool Terraria.Recipe.TryGetIngredient< T > ( out Item  ingredient)
Type Constraints
T :ModItem 
T :TryGetIngredient 
T :ModContent.ItemType<T>() 
T :out 
T :ingredient 

◆ TryGetResult< T >()

bool Terraria.Recipe.TryGetResult< T > ( out Item  result)
Type Constraints
T :ModItem 
T :TryGetResult 
T :ModContent.ItemType<T>() 
T :out 
T :result