Class CraftingRecipeIngredient
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
A crafting recipe ingredient Open in GitHub
[DocumentAsJson]
public class CraftingRecipeIngredient : IRecipeIngredient, IRecipeOutput, IByteSerializable, ICloneable
- Inheritance
-
CraftingRecipeIngredient
- Implements
- Inherited Members
- Extension Methods
Properties
AllowedVariants
When using a wildcard in the item/block code, setting this field will limit the allowed variants
[DocumentAsJson("Optional", "Allow All", false)]
public string[]? AllowedVariants { get; set; }
Property Value
- string[]
Attributes
What attributes this itemstack must have to be a valid ingredient
[JsonProperty]
[JsonConverter(typeof(JsonAttributesConverter))]
[DocumentAsJson("Optional", "None", false)]
public JsonObject? Attributes { get; set; }
Property Value
Break
Determines if and item will be destroyed when reaching zero durability.
[DocumentAsJson("Optional", "True", false)]
public bool Break { get; set; }
Property Value
Code
The code of the item or block.
[DocumentAsJson("Optional", "All", false)]
public AssetLocation? Code { get; set; }
Property Value
Consume
Defines if recipe ingredient should be consumed on crafting.
Is equal to 'not IsTool'. Use this property instead of 'IsTool'.
[DocumentAsJson("Optional", "True", false)]
public bool Consume { get; set; }
Property Value
ConsumeProperties
public RecipeIngredientConsumeProperties ConsumeProperties { get; }
Property Value
DurabilityChange
Defines how item durability will be changed. Durability will be capped at maximum item durability, and wont reduce below 0, unless specific item class changes this behavior.
[DocumentAsJson("Optional", "-1", false)]
public int DurabilityChange { get; set; }
Property Value
Id
Is used to reference recipe ingredient in the recipe, for example to specify where to copy attributes from.
If not specified will be set to the index of this ingredient in the array (starting from 1), or key of this ingredient in the object.
[DocumentAsJson("Optional", "None", false)]
public string Id { get; set; }
Property Value
IsTool
Whether this crafting recipe ingredient should be regarded as a tool required to build this item. If true, the recipe will not consume the item but reduce its durability.
[DocumentAsJson("Optional", "False", false)]
public bool IsTool { get; set; }
Property Value
IsWildCard
[Obsolete("Use MatchingType")]
public bool IsWildCard { get; set; }
Property Value
MatchingType
Defines how Code will be used to match
public EnumRecipeMatchType MatchingType { get; set; }
Property Value
Name
Attaches a name to a wildcard in an ingredient. This is used to substitute the value into the output. Only required if using a wildcard.
[DocumentAsJson("Required", "", false)]
public string? Name { get; set; }
Property Value
Quantity
The quantity of the itemstack required for the recipe. Alias of StackSize.
[DocumentAsJson("Recommended", "1", false)]
public int Quantity { get; set; }
Property Value
RecipeAttributes
Optional attribute data that you can attach any data to. Used for some specific instances in code mods.
[JsonProperty]
[JsonConverter(typeof(JsonAttributesConverter))]
[DocumentAsJson("Optional", "None", false)]
public JsonObject? RecipeAttributes { get; set; }
Property Value
ResolvedItemStack
The itemstack made from Code, Quantity and Attributes, populated by the engine
public ItemStack? ResolvedItemStack { get; set; }
Property Value
ReturnedStack
If set, the crafting recipe will give back the consumed stack to be player upon crafting. Can also be used to produce multiple outputs for a recipe.
[DocumentAsJson("Optional", "None", false)]
public JsonItemStack? ReturnedStack { get; set; }
Property Value
ReverseTagsCheck
When used with [] tags: matched item should contain at least on tag from the list When used with [[]] tags: matched item should contain at least one tag from each group
[DocumentAsJson("Optional", "None", false)]
public bool? ReverseTagsCheck { get; set; }
Property Value
- bool?
SkipVariants
When using a wildcard in the item/block code, setting this field will skip these variants
[DocumentAsJson("Optional", "Skip None", false)]
public string[]? SkipVariants { get; set; }
Property Value
- string[]
StackSize
Amount of items in this stacks
[ProtoMember(3)]
[DocumentAsJson("Optional", "1", false)]
public int StackSize { get; set; }
Property Value
Tags
If array of tags specified (["tag-1", "tag-2", "not-tag-3"]):
- matched item has to have all these tags, and not have tags with 'not-' prefix;
- if 'ReverseTagsCheck: true' specified, matched item has to have at least one of these tags, or not contain any tag with 'not-' prefix.
If array of tag groups specified ([["tag-1", "tag-2"], ["not-tag-3", "tag-4]]): - matched item has to have all tags (and not have 'not-' tags) from at least of tag groups;
- if 'ReverseTagsCheck: true' specified, matched item has to have at least one of these tags, or not contain any tag with 'not-' prefix from each tag group.
This tags check can be treated as logic expression where each tag means of matched item having this tag: - [["tag-1", "tag-2"], ["not-tag-3", "tag-4]] == (tag-1 AND tag-2) OR (NOT tag-3 AND tag-4)
- if 'ReverseTagsCheck: true' specified: [["tag-1", "tag-2"], ["not-tag-3", "tag-4]] == (tag-1 OR tag-2) AND (NOT tag-3 OR tag-4)
[DocumentAsJson("Optional", "All", false)]
public GeneralTagGroups? Tags { get; set; }
Property Value
ToolDurabilityCost
If Consume is set to False, this is the durability cost when the recipe is created.
[DocumentAsJson("Optional", "1", false)]
public int ToolDurabilityCost { get; set; }
Property Value
Type
Is the itemstack an item or a block?
[DocumentAsJson("Recommended", "Block", false)]
public EnumItemClass Type { get; set; }
Property Value
Methods
CheckTags(ItemStack, CollectibleObject)
public virtual bool CheckTags(ItemStack inputStack, CollectibleObject collectible)
Parameters
inputStackItemStackcollectibleCollectibleObject
Returns
Clone()
public virtual CraftingRecipeIngredient Clone()
Returns
CloneTo(object)
protected virtual void CloneTo(object cloneTo)
Parameters
cloneToobject
CloneTo<TResult>()
[Obsolete("Use 'Clone()' instead")]
public TResult CloneTo<TResult>() where TResult : CraftingRecipeIngredient, new()
Returns
- TResult
Type Parameters
TResult
FillPlaceHolder(string, string)
Replaces {key} placeholders with value in code an attributes
public virtual void FillPlaceHolder(string key, string value)
Parameters
FromBytes(BinaryReader, IWorldAccessor)
public virtual void FromBytes(BinaryReader reader, IWorldAccessor resolver)
Parameters
readerBinaryReaderresolverIWorldAccessor
GetConsumeProperties()
public virtual RecipeIngredientConsumeProperties GetConsumeProperties()
Returns
Resolve(IWorldAccessor, string)
public virtual bool Resolve(IWorldAccessor world, string sourceForErrorLogging)
Parameters
worldIWorldAccessorsourceForErrorLoggingstring
Returns
SatisfiesAsIngredient(ItemStack, bool)
public virtual bool SatisfiesAsIngredient(ItemStack inputStack, bool checkStackSize = true)
Parameters
Returns
ToBytes(BinaryWriter)
public virtual void ToBytes(BinaryWriter writer)
Parameters
writerBinaryWriter
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.