Class CraftingRecipeIngredient
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
A crafting recipe ingredient Open in GitHub
[DocumentAsJson]
public class CraftingRecipeIngredient : IRecipeIngredient, IRecipeIngredientBase, IRecipeOutput, IByteSerializable, ICloneable
- Inheritance
-
CraftingRecipeIngredient
- Implements
- Inherited Members
- Extension Methods
Fields
ResolvedAttributes
public ITreeAttribute? ResolvedAttributes
Field Value
defaultEmptyAttributes
public static ITreeAttribute defaultEmptyAttributes
Field Value
resolvedItemStack
Only used if we have not de-duplicated this CraftingRecipeIngredient (e.g. for RightClickConstruction ingredients)
protected ItemStack? resolvedItemStack
Field Value
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. For performance, consider referencing the ResolvedAttributes or Quantity of this CraftingRecipeIngredient instead of the Attributes or StackSize of the ResolvedItemStack, it may save having to clone the ResolvedItemStack
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
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
[DocumentAsJson("Optional", "None", false)]
public ComplexTagCondition<TagSet> 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
CheckTags(ComplexTagCondition<TagSet>, ItemStack, CollectibleObject)
public static bool CheckTags(ComplexTagCondition<TagSet> tags, ItemStack inputStack, CollectibleObject collectible)
Parameters
tagsComplexTagCondition<TagSet>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)
For INPUT slots you should normally call the overload Resolve(IWorldAccessor world, string sourceForErrorLogging, IRecipeBase recipe) otherwise you risk this ingredient/recipe being missed in the Handbook and in grid crafting.
However, it's totally fine to use this overload for OUTPUT slots or for special situations (e.g. RightClickConstruction in the world)
public virtual bool Resolve(IWorldAccessor world, string sourceForErrorLogging)
Parameters
worldIWorldAccessorsourceForErrorLoggingstring
Returns
Resolve(IWorldAccessor, string, IRecipeBase)
For INPUT ingredients this should be used in place of the overload Resolve(IWorldAccessor world, string sourceForErrorLogging), to make use of the de-duplication / fast-search system for ingredients, essential for GridRecipes in the Handbook and in the Crafting Grid
public virtual bool Resolve(IWorldAccessor world, string sourceForErrorLogging, IRecipeBase recipe)
Parameters
worldIWorldAccessorsourceForErrorLoggingstringrecipeIRecipeBase
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.