tModLoader  0.12 Alpha
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 (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. 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. More...
 
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...
 
delegate void ConsumeItemCallback (Recipe recipe, int type, ref int amount)
 
void Create ()
 
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)
 
bool ProcessGroupsForText (int type, out string theText)
 
void 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 (Item item)
 
bool RemoveRecipe ()
 
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)
 
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 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>()
 

Static Public Attributes

static int maxRecipes = 3000
 
static int numRecipes
 

Properties

int RecipeIndex [get]
 The index of the recipe in the Main.recipe array. More...
 

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.

◆ AddConsumeItemCallback()

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

◆ 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
itemThe item.
stackThe stack.
Type Constraints
T :ModItem 
T :AddIngredient 
T :ModContent.ItemType<T>() 
T :stack 

◆ AddOnCraftCallback()

Recipe Terraria.Recipe.AddOnCraftCallback ( OnCraftCallback  callback)

Sets a callback that will allow you to make anything happen when the recipe is used to create an item.

◆ 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.

◆ 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>() 

◆ Register()

void 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.

Property Documentation

◆ RecipeIndex

int Terraria.Recipe.RecipeIndex
get

The index of the recipe in the Main.recipe array.