Class RecipeBase
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Creates a new base recipe type. Almost all recipe types extend from this. Open in GitHub
[DocumentAsJson]
public abstract class RecipeBase : IRecipeBase, IByteSerializable, IConcreteCloneable<RecipeBase>, ICloneable
- Inheritance
-
RecipeBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Fields
CollectiblePreSearchResultsCache
public static readonly CollectiblePreSearchResultsCache CollectiblePreSearchResultsCache
Field Value
Properties
AllowedVariants
If '{code}' is used in ingredient code, allowed variants for this code should be specified in this map
[DocumentAsJson("Optional", "None", false)]
public Dictionary<string, string[]> AllowedVariants { get; set; }
Property Value
- Dictionary<string, string[]>
Attributes
Optional attribute data that you can attach any data to. Useful for code mods, but also required when using liquid ingredients.
See dough.json grid recipe file for example.
[JsonConverter(typeof(JsonAttributesConverter))]
[DocumentAsJson("Optional", "None", false)]
public JsonObject? Attributes { get; set; }
Property Value
AverageDurability
If true, the output item will have its durability averaged over the input items
[DocumentAsJson("Optional", "True", false)]
public bool AverageDurability { get; set; }
Property Value
CopyAttributesFrom
If set, it will copy over the itemstack attributes from given ingredient code
[DocumentAsJson("Optional", "None", false)]
public string? CopyAttributesFrom { get; set; }
Property Value
Enabled
If set to false, the recipe will never be loaded. If loaded, you can use this field to disable recipes during runtime.
[DocumentAsJson("Optional", "True", false)]
public bool Enabled { get; set; }
Property Value
MergeAttributesFrom
Attributes from these ingredients will be merged into output itemstack
[DocumentAsJson("Optional", "None", false)]
public string[] MergeAttributesFrom { get; set; }
Property Value
- string[]
Name
Adds a name to this. Used for logging, and determining helve hammer workability for smithing recipes. Recipes for repairing objects must contain 'repair' in the name.
[DocumentAsJson("Optional", "Asset Path", false)]
public AssetLocation? Name { get; set; }
Property Value
RecipeId
The ID of the Automatically generated when the recipe is loaded.
public int RecipeId { get; set; }
Property Value
RecipeIngredients
public abstract IEnumerable<IRecipeIngredient> RecipeIngredients { get; }
Property Value
RecipeOutput
public abstract IRecipeOutput RecipeOutput { get; }
Property Value
RequiresTrait
If set, only players with given trait can use this See config/traits.json for a list of traits.
[DocumentAsJson("Optional", "None", false)]
public string? RequiresTrait { get; set; }
Property Value
ShowInCreatedBy
Used by the handbook. If false, will not appear in the "Created by" section
[DocumentAsJson("Optional", "True", false)]
public bool ShowInCreatedBy { get; set; }
Property Value
SkipVariants
If '{code}' is used in ingredient code, skip variants for this code should be specified in this map
[DocumentAsJson("Optional", "None", false)]
public Dictionary<string, string[]> SkipVariants { get; set; }
Property Value
- Dictionary<string, string[]>
Methods
AddVariantCombination(Dictionary<string, HashSet<string>>, Dictionary<string, string>)
protected virtual void AddVariantCombination(Dictionary<string, HashSet<string>> variantValues, Dictionary<string, string> combination)
Parameters
variantValuesDictionary<string, HashSet<string>>combinationDictionary<string, string>
AddVariantValuesToMapping(Dictionary<string, HashSet<string>>, Dictionary<string, HashSet<string>>)
protected virtual void AddVariantValuesToMapping(Dictionary<string, HashSet<string>> mappings, Dictionary<string, HashSet<string>> variantValues)
Parameters
mappingsDictionary<string, HashSet<string>>variantValuesDictionary<string, HashSet<string>>
Clone()
public abstract RecipeBase Clone()
Returns
CloneTo(object)
protected virtual void CloneTo(object recipe)
Parameters
recipeobject
CollectVariantValues(Match, List<string>, Dictionary<string, HashSet<string>>)
protected virtual void CollectVariantValues(Match match, List<string> variants, Dictionary<string, HashSet<string>> variantCodes)
Parameters
ConsumeExactMatchIngredient(ItemStack, ItemSlot, ItemSlot[], List<IRecipeIngredient>, IPlayer)
protected virtual void ConsumeExactMatchIngredient(ItemStack inputStack, ItemSlot inputSlot, ItemSlot[] inputSlots, List<IRecipeIngredient> exactMatchIngredients, IPlayer byPlayer)
Parameters
inputStackItemStackinputSlotItemSlotinputSlotsItemSlot[]exactMatchIngredientsList<IRecipeIngredient>byPlayerIPlayer
ConsumeInputAt(IPlayer, ItemSlot[], int, int, int, int, IRecipeIngredient?[])
protected virtual bool ConsumeInputAt(IPlayer byPlayer, ItemSlot[] inputSlots, int gridWidth, int recipeWidth, int colStart, int rowStart, IRecipeIngredient?[] ingredients)
Parameters
byPlayerIPlayerinputSlotsItemSlot[]gridWidthintrecipeWidthintcolStartintrowStartintingredientsIRecipeIngredient[]
Returns
ConsumeInputAt(IPlayer, ItemSlot[], IRecipeIngredient?[])
protected virtual bool ConsumeInputAt(IPlayer byPlayer, ItemSlot[] inputSlots, IRecipeIngredient?[] ingredients)
Parameters
byPlayerIPlayerinputSlotsItemSlot[]ingredientsIRecipeIngredient[]
Returns
ConsumeInputShapeLess(IPlayer, ItemSlot[], IRecipeIngredient?[])
protected virtual bool ConsumeInputShapeLess(IPlayer byPlayer, ItemSlot[] inputSlots, IRecipeIngredient?[] ingredients)
Parameters
byPlayerIPlayerinputSlotsItemSlot[]ingredientsIRecipeIngredient[]
Returns
ConsumeWildcardMatchIngredient(ItemStack, ItemSlot, ItemSlot[], List<IRecipeIngredient>, IPlayer)
protected virtual void ConsumeWildcardMatchIngredient(ItemStack inputStack, ItemSlot inputSlot, ItemSlot[] inputSlots, List<IRecipeIngredient> wildcardAndToolIngredients, IPlayer byPlayer)
Parameters
inputStackItemStackinputSlotItemSlotinputSlotsItemSlot[]wildcardAndToolIngredientsList<IRecipeIngredient>byPlayerIPlayer
FillIngredientPlaceHolders(IRecipeIngredient, string, string)
protected virtual void FillIngredientPlaceHolders(IRecipeIngredient ingredient, string variantCode, string variantValue)
Parameters
ingredientIRecipeIngredientvariantCodestringvariantValuestring
FromBytes(BinaryReader, IWorldAccessor)
public virtual void FromBytes(BinaryReader reader, IWorldAccessor resolver)
Parameters
readerBinaryReaderresolverIWorldAccessor
GenerateAllowedVariantsCombinations(Dictionary<string, string[]>)
protected virtual List<Dictionary<string, string>> GenerateAllowedVariantsCombinations(Dictionary<string, string[]> allowedVariants)
Parameters
allowedVariantsDictionary<string, string[]>
Returns
GenerateAllowedVariantsCombinationsRecursive(int, string[], IEnumerable<(string variant, string value)>, Dictionary<string, string[]>, List<Dictionary<string, string>>)
protected virtual void GenerateAllowedVariantsCombinationsRecursive(int index, string[] variants, IEnumerable<(string variant, string value)> combination, Dictionary<string, string[]> allowedVariants, List<Dictionary<string, string>> combinations)
Parameters
indexintvariantsstring[]combinationIEnumerable<(string variant, string value)>allowedVariantsDictionary<string, string[]>combinationsList<Dictionary<string, string>>
GenerateOutputStack(ItemSlot[], ItemSlot)
public virtual void GenerateOutputStack(ItemSlot[] inputSlots, ItemSlot outputSlot)
Parameters
GenerateRecipesForAllIngredientCombinations(IWorldAccessor)
public virtual IEnumerable<IRecipeBase> GenerateRecipesForAllIngredientCombinations(IWorldAccessor world)
Parameters
worldIWorldAccessor
Returns
GenerateRecipesForTagOnlyIngredients(IWorldAccessor, IRecipeBase)
protected virtual IEnumerable<IRecipeBase> GenerateRecipesForTagOnlyIngredients(IWorldAccessor world, IRecipeBase recipe)
Parameters
worldIWorldAccessorrecipeIRecipeBase
Returns
GetElementInGrid<TGridCellElement>(int, int, TGridCellElement[], int)
public virtual TGridCellElement? GetElementInGrid<TGridCellElement>(int row, int column, TGridCellElement[] cells, int gridWidth)
Parameters
Returns
- TGridCellElement
Type Parameters
TGridCellElement
GetGridIndex<TGridCellElement>(int, int, TGridCellElement[], int)
public virtual int GetGridIndex<TGridCellElement>(int row, int col, TGridCellElement[] cells, int gridWidth)
Parameters
Returns
Type Parameters
TGridCellElement
GetIngredientById(string)
protected virtual IRecipeIngredient? GetIngredientById(string id)
Parameters
idstring
Returns
GetInputStackForIngredientId(string, ItemSlot[])
protected virtual ItemStack? GetInputStackForIngredientId(string id, ItemSlot[] inputSlots)
Parameters
Returns
GetNameToCodeMapping(IWorldAccessor)
protected virtual Dictionary<string, HashSet<string>> GetNameToCodeMapping(IWorldAccessor world)
Parameters
worldIWorldAccessor
Returns
GetNameToCodeMappingForAdvancedWildcard(IWorldAccessor, IRecipeIngredient, Dictionary<string, HashSet<string>>)
protected virtual void GetNameToCodeMappingForAdvancedWildcard(IWorldAccessor world, IRecipeIngredient ingredient, Dictionary<string, HashSet<string>> mappings)
Parameters
worldIWorldAccessoringredientIRecipeIngredientmappingsDictionary<string, HashSet<string>>
GetNameToCodeMappingForBasicWildcard(IWorldAccessor, IRecipeIngredient, Dictionary<string, HashSet<string>>)
protected virtual void GetNameToCodeMappingForBasicWildcard(IWorldAccessor world, IRecipeIngredient ingredient, Dictionary<string, HashSet<string>> mappings)
Parameters
worldIWorldAccessoringredientIRecipeIngredientmappingsDictionary<string, HashSet<string>>
GetVariantValuesFromAdvancedWildcard(IRecipeIngredient, IEnumerable<CollectibleObject>, Dictionary<string, string>)
protected virtual Dictionary<string, HashSet<string>> GetVariantValuesFromAdvancedWildcard(IRecipeIngredient ingredient, IEnumerable<CollectibleObject> collectibles, Dictionary<string, string> allowedVariantsCombination)
Parameters
ingredientIRecipeIngredientcollectiblesIEnumerable<CollectibleObject>allowedVariantsCombinationDictionary<string, string>
Returns
MatchIngredientStacks(List<(ItemStack stack, IRecipeIngredient ingredient)>, List<ItemStack>)
protected virtual bool MatchIngredientStacks(List<(ItemStack stack, IRecipeIngredient ingredient)> ingredientStacks, List<ItemStack> suppliedStacks)
Parameters
ingredientStacksList<(ItemStack stack, IRecipeIngredient ingredient)>suppliedStacksList<ItemStack>
Returns
MatchStackToIngredient(ItemStack?, IRecipeIngredient?)
protected virtual bool MatchStackToIngredient(ItemStack? inputStack, IRecipeIngredient? ingredient)
Parameters
inputStackItemStackingredientIRecipeIngredient
Returns
MatchWildcardIngredients(List<ItemStack>, IRecipeIngredient?[])
protected virtual bool MatchWildcardIngredients(List<ItemStack> suppliedStacks, IRecipeIngredient?[] ingredients)
Parameters
suppliedStacksList<ItemStack>ingredientsIRecipeIngredient[]
Returns
MatchesAtPosition(int, int, ItemSlot[], int, int, IRecipeIngredient?[])
protected virtual bool MatchesAtPosition(int colStart, int rowStart, ItemSlot[] inputSlots, int gridWidth, int recipeWidth, IRecipeIngredient?[] ingredients)
Parameters
colStartintrowStartintinputSlotsItemSlot[]gridWidthintrecipeWidthintingredientsIRecipeIngredient[]
Returns
MatchesAtPosition(ItemSlot[], IRecipeIngredient?[])
protected virtual bool MatchesAtPosition(ItemSlot[] inputSlots, IRecipeIngredient?[] ingredients)
Parameters
inputSlotsItemSlot[]ingredientsIRecipeIngredient[]
Returns
MatchesShapeLess(ItemSlot[], IWorldAccessor, IRecipeIngredient?[])
protected virtual bool MatchesShapeLess(ItemSlot[] suppliedSlots, IWorldAccessor world, IRecipeIngredient?[] ingredients)
Parameters
suppliedSlotsItemSlot[]worldIWorldAccessoringredientsIRecipeIngredient[]
Returns
MergeIngredientStacks(ItemSlot[], List<(ItemStack stack, IRecipeIngredient ingredient)>, IRecipeIngredient?[], IWorldAccessor)
protected virtual void MergeIngredientStacks(ItemSlot[] slots, List<(ItemStack stack, IRecipeIngredient ingredient)> stacks, IRecipeIngredient?[] ingredients, IWorldAccessor world)
Parameters
slotsItemSlot[]stacksList<(ItemStack stack, IRecipeIngredient ingredient)>ingredientsIRecipeIngredient[]worldIWorldAccessor
MergeStacks(ItemSlot[], List<ItemStack>)
protected virtual void MergeStacks(ItemSlot[] slots, List<ItemStack> stacks)
Parameters
OnParsed(IWorldAccessor)
public virtual void OnParsed(IWorldAccessor world)
Parameters
worldIWorldAccessor
ReplaceVariantsToRegex(string, out List<string>, Dictionary<string, string>?)
public static string ReplaceVariantsToRegex(string value, out List<string> variants, Dictionary<string, string>? allowedVariants = null)
Parameters
Returns
Resolve(IWorldAccessor, string)
public abstract bool Resolve(IWorldAccessor world, string sourceForErrorLogging)
Parameters
worldIWorldAccessorsourceForErrorLoggingstring
Returns
SeparateAndMergeIngredients(IRecipeIngredient?[], List<IRecipeIngredient>, List<IRecipeIngredient>)
protected virtual void SeparateAndMergeIngredients(IRecipeIngredient?[] ingredients, List<IRecipeIngredient> exactMatchIngredients, List<IRecipeIngredient> wildcardAndToolIngredients)
Parameters
ingredientsIRecipeIngredient[]exactMatchIngredientsList<IRecipeIngredient>wildcardAndToolIngredientsList<IRecipeIngredient>
ToBytes(BinaryWriter)
public virtual void ToBytes(BinaryWriter writer)
Parameters
writerBinaryWriter
WildCardToRegex(string)
public static string WildCardToRegex(string value)
Parameters
valuestring