TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ Register()

Recipe Terraria.Recipe.Register ( )
inline

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

Exceptions
T:Terraria.ModLoader.Exceptions.RecipeExceptionA recipe without any result has been added.

Definition at line 16587 of file Recipe.cs.

16588 {
16589 if (createItem == null || createItem.type == 0)
16590 {
16591 throw new RecipeException("A recipe without any result has been added.");
16592 }
16593 if (RecipeIndex >= 0)
16594 {
16595 throw new RecipeException("There was an attempt to register an already registered recipe.");
16596 }
16597 if (requiredTile.Contains(13))
16598 {
16599 AddConsumeItemCallback(ConsumptionRules.Alchemy);
16600 }
16601 if (numRecipes >= maxRecipes)
16602 {
16603 maxRecipes += 500;
16604 Array.Resize(ref Main.recipe, maxRecipes);
16605 Array.Resize(ref Main.availableRecipe, maxRecipes);
16606 Array.Resize(ref Main.availableRecipeY, maxRecipes);
16607 for (int i = numRecipes; i < maxRecipes; i++)
16608 {
16609 Main.recipe[i] = new Recipe();
16610 Main.availableRecipeY[i] = 65f * (float)i;
16611 }
16612 }
16613 Main.recipe[numRecipes] = this;
16615 numRecipes++;
16617 {
16619 }
16620 return this;
16621 }
int type
The Item ID of this item. The Item ID is a unique number assigned to each Item loaded into the game....
Definition Item.cs:345
This is where all Recipe hooks are gathered and called.
List< int > requiredTile
Definition Recipe.cs:66
int RecipeIndex
The index of the recipe in the Main.recipe array.
Definition Recipe.cs:121
Recipe AddConsumeItemCallback(ConsumeItemCallback callback)
Sets a callback that allows you to determine how many of a certain ingredient is consumed when this r...
Definition Recipe.cs:16456
Item createItem
Definition Recipe.cs:62
static int numRecipes
Definition Recipe.cs:58
static int maxRecipes
Definition Recipe.cs:56
static Recipe()
Definition Recipe.cs:130

References Terraria.Recipe.Recipe(), Terraria.Recipe.AddConsumeItemCallback(), Terraria.Recipe.ConsumptionRules.Alchemy, Terraria.Main.availableRecipe, Terraria.Main.availableRecipeY, Terraria.Recipe.createItem, Terraria.ModLoader.RecipeLoader.FirstRecipeForItem, Terraria.Recipe.maxRecipes, Terraria.Recipe.numRecipes, Terraria.Main.recipe, Terraria.Recipe.RecipeIndex, Terraria.Recipe.requiredTile, and Terraria.Item.type.

+ Here is the call graph for this function: