TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
Terraria.Recipe Class Referencesealed

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 M:Terraria.Recipe.Create(System.Int32,System.Int32) to create a Recipe instance resulting in the specified item. Use M:Terraria.Recipe.AddIngredient(System.Int32,System.Int32) to add ingredients and M:Terraria.Recipe.AddTile(System.Int32) to add crafting stations. Finally, use M:Terraria.Recipe.Register to complete the recipe and register it to the game.
Recipes can only be added in M:Terraria.ModLoader.ModSystem.AddRecipes, M:Terraria.ModLoader.ModItem.AddRecipes, and M:Terraria.ModLoader.GlobalItem.AddRecipes.
Recipes should be edited only in M:Terraria.ModLoader.ModSystem.PostAddRecipes. More...

+ Collaboration diagram for Terraria.Recipe:

Classes

class  ConsumptionRules
 
struct  RequiredItemEntry
 

Public Member Functions

delegate void OnCraftCallback (Recipe recipe, Item item, List< Item > consumedItems, Item destinationStack)
 
delegate void ConsumeItemCallback (Recipe recipe, int type, ref int amount)
 
void RequireGroup (int id)
 
bool ProcessGroupsForText (int type, out string theText)
 
bool AcceptsGroup (int groupId)
 
bool AcceptedByItemGroups (int invType, int reqType)
 
Recipe AddCustomShimmerResult (int itemType, int itemStack=1)
 
void Create ()
 
bool ContainsIngredient (int itemType)
 
bool HasResult (int itemID)
 
bool HasResult (Mod mod, string itemName)
 
bool HasResult (ModItem item)
 
bool HasResult< T > ()
 
bool HasIngredient (int itemID)
 
bool HasIngredient (Mod mod, string itemName)
 
bool HasIngredient (ModItem item)
 
bool HasIngredient< T > ()
 
bool HasRecipeGroup (int id)
 
bool HasRecipeGroup (string name)
 
bool HasRecipeGroup (RecipeGroup group)
 
bool HasTile (int tileID)
 
bool HasTile (Mod mod, string tileName)
 
bool HasTile (ModTile tile)
 
bool HasTile< T > ()
 
bool HasCondition (Condition condition)
 
bool HasShimmerCondition (Condition condition)
 
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)
 
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 RemoveIngredient (Item item)
 
bool RemoveIngredient (int itemID)
 
bool RemoveTile (int tileID)
 
bool RemoveRecipeGroup (int groupID)
 
bool RemoveCondition (Condition condition)
 
bool RemoveShimmerCondition (Condition condition)
 
void DisableRecipe ()
 
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 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)
 
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.
 
Recipe AddIngredient (ModItem item, int stack=1)
 Adds an ingredient to this recipe of the given type of item and stack size.
 
Recipe AddIngredient< T > (int stack=1)
 Adds an ingredient to this recipe of the given type of item and stack size.
 
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 F:Terraria.ID.ItemID.IronBar or F:Terraria.ID.ItemID.LeadBar. The Recipe Groups wiki guidehas more information.
To use a vanilla recipe group, use M:Terraria.Recipe.AddRecipeGroup(System.Int32,System.Int32) using a T:Terraria.ID.RecipeGroupID entry instead.
 
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 F:Terraria.ID.RecipeGroupID.IronBar group accepts either F:Terraria.ID.ItemID.IronBar or F:Terraria.ID.ItemID.LeadBar. The Recipe Groups wiki guidehas more information.
Vanilla recipe group IDs can be found in T:Terraria.ID.RecipeGroupID and modded recipe group IDs will be returned from M:Terraria.RecipeGroup.RegisterGroup(System.String,Terraria.RecipeGroup). M:Terraria.Recipe.AddRecipeGroup(System.String,System.Int32) can be used instead if the ID number is not known but the name is known.
 
Recipe AddRecipeGroup (RecipeGroup recipeGroup, int stack=1)
 Adds a recipe group ingredient to this recipe with the given RecipeGroup.
 
Recipe AddTile (int tileID)
 Adds a required crafting station with the given tile type to this recipe. Ex: recipe.AddTile(TileID.WorkBenches)
 
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.
 
Recipe AddTile (ModTile tile)
 Adds a required crafting station to this recipe of the given type of tile.
 
Recipe AddTile< T > ()
 Adds a required crafting station to this recipe of the given type of tile.
 
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).
 
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).
 
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).
 
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).
 
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).
 
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).
 
Recipe ApplyConditionsAsDecraftConditions ()
 Adds every condition from Recipe.Conditions to Recipe.DecraftConditions, checking for duplicates.
 
Recipe DisableDecraft ()
 Sets a check that is used during load to prevent this being shimmered/decrafted.
 
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 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 SortBeforeFirstRecipesOf (int itemId)
 Sorts the recipe before 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 SortAfterFirstRecipesOf (int itemId)
 Sorts the recipe after the first one creating the item of the ID given as parameter.
 
Recipe SortAfter (Recipe recipe)
 Sorts the recipe after the one given as parameter. Both recipes must already be registered.
 
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.
 
Recipe Register ()
 Adds this recipe to the game. Call this after you have finished setting the result, ingredients, etc.
 

Static Public Member Functions

static void GetThroughDelayedFindRecipes ()
 
static void FindRecipes (bool canDelayCheck=false)
 
static bool CollectedEnoughItemsToCraftRecipeOld (Recipe tempRec)
 
static bool CollectedEnoughItemsToCraftRecipeNew (Recipe tempRec)
 
static void ClearAvailableRecipes ()
 
static void SetupRecipeGroups ()
 
static void UpdateItemVariants ()
 
static void SetupRecipes ()
 
static void UpdateWhichItemsAreMaterials ()
 
static void UpdateWhichItemsAreCrafted ()
 
static int GetRequiredTileStyle (int tileID)
 
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.
 

Public Attributes

Item createItem = new Item()
 
List< ItemrequiredItem = new List<Item>()
 
List< int > requiredTile = new List<int>()
 
List< int > acceptedGroups = new List<int>()
 
List< ItemcustomShimmerResults
 
readonly Mod Mod
 
readonly List< ConditionConditions = new List<Condition>()
 
readonly List< ConditionDecraftConditions = new List<Condition>()
 
Recipe target
 

Static Public Attributes

static int maxRecipes
 
static int numRecipes
 

Package Functions

 Recipe (Mod mod=null)
 

Package Attributes

bool needHoney
 
bool needWater
 
bool needLava
 
bool anyWood
 
bool anyIronBar
 
bool anyPressurePlate
 
bool anySand
 
bool anyFragment
 
bool alchemy
 
bool needSnowBiome
 
bool needGraveyardBiome
 
bool needEverythingSeed
 
bool notDecraftable
 
bool crimson
 
bool corruption
 

Properties

OnCraftCallback OnCraftHooks [get, private set]
 
ConsumeItemCallback ConsumeItemHooks [get, private set]
 
int RecipeIndex [get, set]
 The index of the recipe in the Main.recipe array.
 
Recipe bool after Ordering [get, set]
 
bool Disabled [get, private set]
 Any recipe with this flag won't be shown in game.
 

Private Member Functions

void RequireGroup (string name)
 
bool ConsumeForCraft (Item item, Item requiredItem, ref int stackRequired)
 
bool useWood (int invType, int reqType)
 
bool useIronBar (int invType, int reqType)
 
bool useSand (int invType, int reqType)
 
bool useFragment (int invType, int reqType)
 
bool usePressurePlate (int invType, int reqType)
 
void ReplaceItemUseFlagWithGroup (ref bool flag, int groupId)
 
void SetIngredients (params int[] ingredients)
 
void SetCraftingStation (params int[] tileIDs)
 
void AddGroup (int id)
 
Recipe SetOrdering (Recipe recipe, bool after)
 Sets the Ordering of this recipe. This recipe can't already have one.
 

Static Private Member Functions

static Recipe ()
 
static void AddToAvailableRecipes (int recipeIndex)
 
static bool PlayerMeetsEnvironmentConditions (Player player, Recipe tempRec)
 
static bool PlayerMeetsTileRequirements (Player player, Recipe tempRec)
 
static void CollectItemsToCraftWithFrom (Player player)
 
static void AddFakeCountsForItemGroups ()
 
static void CollectItems (Item[] currentInventory, int slotCap)
 
static void CollectItems (IEnumerable< Item > items)
 
static void CollectGuideRecipes ()
 
static void VisuallyRepositionRecipes (float focusY)
 
static void TryRefocusingRecipe (int oldRecipe)
 
static void ReplaceItemUseFlagsWithRecipeGroups ()
 
static void CreateRequiredItemQuickLookups ()
 
static void UpdateMaterialFieldForAllRecipes ()
 
static void AddSolarFurniture ()
 
static void AddVortexFurniture ()
 
static void AddNebulaFurniture ()
 
static void AddStardustFurniture ()
 
static void AddSpiderFurniture ()
 
static void AddLesionFurniture ()
 
static void AddSandstoneFurniture ()
 
static void AddBambooFurniture ()
 
static void AddCoralFurniture ()
 
static void AddBalloonFurniture ()
 
static void AddAshWoodFurnitureArmorAndItems ()
 
static void CreateReversePlatformRecipes ()
 
static void CreateReverseWallRecipes ()
 
static void AddRecipe ()
 
static void ResetCurrentRecipe ()
 
static void FixRecipeGroups ()
 

Private Attributes

RequiredItemEntry[] requiredItemQuickLookup
 

Static Private Attributes

static int maxVanillaRequirements
 
static Recipe currentRecipe
 
static bool _hasDelayedFindRecipes
 
static Dictionary< int, int > _ownedItems
 

Detailed Description

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 M:Terraria.Recipe.Create(System.Int32,System.Int32) to create a Recipe instance resulting in the specified item. Use M:Terraria.Recipe.AddIngredient(System.Int32,System.Int32) to add ingredients and M:Terraria.Recipe.AddTile(System.Int32) to add crafting stations. Finally, use M:Terraria.Recipe.Register to complete the recipe and register it to the game.
Recipes can only be added in M:Terraria.ModLoader.ModSystem.AddRecipes, M:Terraria.ModLoader.ModItem.AddRecipes, and M:Terraria.ModLoader.GlobalItem.AddRecipes.
Recipes should be edited only in M:Terraria.ModLoader.ModSystem.PostAddRecipes.

Definition at line 21 of file Recipe.cs.


The documentation for this class was generated from the following file: