30 throw new RecipeException(
"A ModRecipe can only be created inside recipe related methods");
40 this.createItem.SetDefaults(itemID,
false);
41 this.createItem.stack = stack;
57 string message =
"The item " + itemName +
" does not exist in the mod " + mod.Name +
"." +
Environment.NewLine;
58 message +=
"If you are trying to use a vanilla item, try removing the first argument.";
80 throw new RecipeException(
"Recipe already has maximum number of ingredients. 14 is the max.");
99 string message =
"The item " + itemName +
" does not exist in the mod " + mod.Name +
"." +
Environment.NewLine;
100 message +=
"If you are trying to use a vanilla item, try removing the first argument.";
122 if (!RecipeGroup.recipeGroupIDs.ContainsKey(name)) {
123 throw new RecipeException(
"A recipe group with the name " + name +
" does not exist.");
125 int id = RecipeGroup.recipeGroupIDs[name];
126 RecipeGroup rec = RecipeGroup.recipeGroups[id];
128 acceptedGroups.Add(
id);
139 if (!RecipeGroup.recipeGroups.ContainsKey(recipeGroupID)) {
140 throw new RecipeException(
"A recipe group with the ID " + recipeGroupID +
" does not exist.");
142 RecipeGroup rec = RecipeGroup.recipeGroups[recipeGroupID];
144 acceptedGroups.Add(recipeGroupID);
154 throw new RecipeException(
"Recipe already has maximum number of tiles. 14 is the max.");
158 this.requiredTile[
numTiles] = tileID;
174 string message =
"The tile " + tileName +
" does not exist in the mod " + mod.Name +
"." +
Environment.NewLine;
175 message +=
"If you are trying to use a vanilla tile, try using ModRecipe.AddTile(tileID).";
222 if (this.createItem ==
null || this.createItem.type == 0) {
223 throw new RecipeException(
"A recipe without any result has been added.");
225 if (this.numIngredients > 14 || this.numTiles > 14) {
226 throw new RecipeException(
"A recipe with either too many tiles or too many ingredients has been added. 14 is the maximum amount.");
228 for (
int k = 0; k < Recipe.maxRequirements; k++) {
229 if (this.requiredTile[k] == TileID.Bottles) {
234 if (Recipe.numRecipes >= Recipe.maxRecipes) {
235 Recipe.maxRecipes += 500;
236 Array.Resize(ref Main.recipe, Recipe.maxRecipes);
237 Array.Resize(ref Main.availableRecipe, Recipe.maxRecipes);
238 Array.Resize(ref Main.availableRecipeY, Recipe.maxRecipes);
239 for (
int k = Recipe.numRecipes; k < Recipe.maxRecipes; k++) {
240 Main.recipe[k] =
new Recipe();
241 Main.availableRecipeY[k] = 65f * k;
244 Main.recipe[Recipe.numRecipes] =
this;
245 this.RecipeIndex = Recipe.numRecipes;
246 mod.recipes.Add(
this);
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
int TileType(string name)
Gets the type of the ModTile of this mod with the given name. Returns 0 if no ModTile with the given ...
int ItemType(string name)
Gets the internal ID / type of the ModItem corresponding to the name. Returns 0 if no ModItem with th...
This class serves as a place for you to place all your properties and hooks for each item....
Item item
The item object that this ModItem controls.
This class extends Terraria.Recipe, meaning you can use it in a similar manner to vanilla recipes....
int RecipeIndex
The index of the recipe in the Main.recipe array.
void AddRecipeGroup(string name, int stack=1)
Adds a recipe group ingredient to this recipe with the given RecipeGroup name and stack size....
void AddIngredient(int itemID, int stack=1)
Adds an ingredient to this recipe with the given item type and stack size. Ex: recipe....
virtual int ConsumeItem(int type, int numRequired)
Allows you to determine how many of a certain ingredient is consumed when this recipe is used....
void AddTile(ModTile tile)
Adds a required crafting station to this recipe of the given type of tile.
void AddTile(int tileID)
Adds a required crafting station with the given tile type to this recipe. Ex: recipe....
void AddIngredient(ModItem item, int stack=1)
Adds an ingredient to this recipe of the given type of item and stack size.
void SetResult(ModItem item, int stack=1)
Sets the result of this recipe to the given type of item and stack size. Useful in ModItem....
void AddRecipeGroup(int recipeGroupID, int stack=1)
Adds a recipe group ingredient to this recipe with the given RecipeGroupID and stack size....
void 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 sta...
virtual bool RecipeAvailable()
Whether or not the conditions are met for this recipe to be available for the player to use....
virtual void OnCraft(Item item)
Allows you to make anything happen when the player uses this recipe. The item parameter is the item ...
void SetResult(Mod mod, string itemName, int stack=1)
Sets the result of this recipe with the given item name from the given mod, and with the given stack ...
void AddRecipe()
Adds this recipe to the game. Call this after you have finished setting the result,...
ModRecipe(Mod mod)
Constructor
void SetResult(int itemID, int stack=1)
Sets the result of this recipe with the given item type and stack size.
void AddTile(Mod mod, string tileName)
Adds a required crafting station to this recipe with the given tile name from the given mod....
This class represents a type of tile that can be added by a mod. Only one instance of this class will...
ushort Type
The internal ID of this type of tile.
This is where all ModRecipe and GlobalRecipe hooks are gathered and called.
This serves as the central class from which tile-related functions are supported and carried out.
@ Environment
Sandstorm, Hell, Above surface during Eclipse, Space