Repository navigation
Recipes
A recipe tells the game which ingredients make an item and at which crafting
station. Recipes are written exactly as in tModLoader: you create them in an
AddRecipes method, list the ingredients and the station, and register them. A
recipe can make one of your items or one of the game's.
As in tModLoader, a recipe is the game's Recipe, created in AddRecipes
(of the Mod, a ModSystem, a ModItem or a GlobalItem):
public override void AddRecipes()
{
CreateRecipe(999)
.AddIngredient(ItemID.DirtBlock, 10)
.AddRecipeGroup(RecipeGroups.IronBar, 2)
.AddTile(TileID.WorkBenches)
.AddCondition(Condition.NearWater)
.Register();
}Recipe.Create(result, amount) and Mod.CreateRecipe(result, amount) do the
same for any item. A recipe takes at most 15 ingredients (the game's limit;
one more throws RecipeException) and one crafting station. The rest is
tModLoader's: AddIngredient<T>(), AddIngredient(Mod, "Name"),
AddRecipeGroup (by object, registered id or key: "Wood", "IronBar"...),
AddCondition (a Condition, or a LocalizedText and a Func<bool>),
AddOnCraftCallback, AddConsumeIngredientCallback (how many of an
ingredient is used, after the Alchemy Table's discount), DisableDecraft,
Clone, DisableRecipe, and to change recipes in PostAddRecipes:
TryGetIngredient, RemoveIngredient, RemoveCondition, ReplaceResult,
HasIngredient, HasTile... (Main.recipe[i] up to Recipe.numRecipes).
Condition has tModLoader's ready ones (NearWater, TimeNight,
InDesert, Hardmode...). Its text comes from the translation key; without
one, from the key's last word (Conditions.NearWater reads "Near Water").
A recipe whose condition fails, or a disabled one, leaves the crafting menu;
the Guide still lists it, unless it is disabled.
Groups go in AddRecipeGroups:
ExampleRecipeGroup = RecipeGroup.Register("ExampleMod:ExampleItem",
ModContent.GetInstance<ExampleItem>().DisplayName.Key, ModContent.ItemType<ExampleItem>());
RecipeGroups.Bugs.Add(ModContent.ItemType<MyBug>());The text is "Any ". Register(key, () => "Text", items)
shows the function's text instead. Registering a key that exists (yours,
another mod's, or a game group's name: "SilverBar") adds the items to that
group, as in tModLoader. The phone's ValidItems is a game HashSet that C#
cannot reach yet: add items with group.Add(type).
A recipe can be moved in the crafting list, as in tModLoader:
SortBefore(recipe) and SortAfter(recipe) put it next to another recipe,
and SortBeforeFirstRecipesOf(item) and SortAfterFirstRecipesOf(item) next
to the first recipe that makes that item. Mod tiles work as crafting stations
with AddTile<T>() (see Tiles).
Not on the phone yet: DecraftConditions are kept but the Shimmer does not
read them (DisableDecraft does work). The game has 3603 recipes
and stops at 3700: the ones past it are added by Bunny Loader to the crafting
menu and the Guide. Crafting runs ModItem.OnCreated and
GlobalItem.OnCreated with a RecipeItemCreationContext.
The Chlorophyte Extractinator trades through ItemTrader. In
SetStaticDefaults, ItemTrader.ChlorophyteExtractinator.AddOption_OneWay(Type, 5, ItemID.ChlorophyteBar, 2) takes 5 of your item and gives 2 bars. The plain
Extractinator rolls by ItemID.Sets.ExtractinatorMode, and
ModItem.ExtractinatorUse and GlobalItem.ExtractinatorUse can change what comes out.
Bunny Loader wiki ·
Discord ·
Repository ·
BL Editor
Written for Bunny Loader 0.5.5-beta and Terraria Mobile 1.4.5.8.6.
Bunny Loader is not affiliated with Re-Logic or 505 Games.
