Table of Contents

Class GridRecipe

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

Represents a crafting recipe

public class GridRecipe : IByteSerializable
Inheritance
GridRecipe
Implements
Inherited Members
Extension Methods

Fields

Attributes

Optional attribute data that you can attach any data to

[JsonConverter(typeof(JsonAttributesConverter))]
public JsonObject Attributes

Field Value

JsonObject

AverageDurability

If true, the output item will have its durability averaged over the input items

public bool AverageDurability

Field Value

bool

CopyAttributesFrom

If set, it will copy over the itemstack attributes from given ingredient code

public string CopyAttributesFrom

Field Value

string

Enabled

Set by the recipe loader during json deserialization, if false the recipe will never be loaded. If loaded however, you can use this field to disable recipes during runtime.

public bool Enabled

Field Value

bool

Height

Required grid height for crafting this recipe

public int Height

Field Value

int

IngredientPattern

The pattern of the ingredient. Order for a 3x3 recipe: 1 2 3 4 5 6 7 8 9 Order for a 2x2 recipe: 1 2 3 4

public string IngredientPattern

Field Value

string

Ingredients

The recipes ingredients in any order

public Dictionary<string, CraftingRecipeIngredient> Ingredients

Field Value

Dictionary<string, CraftingRecipeIngredient>

Name

Name of the recipe, optional

public AssetLocation Name

Field Value

AssetLocation

Output

The resulting Stack

public CraftingRecipeIngredient Output

Field Value

CraftingRecipeIngredient

RecipeGroup

Info used by the handbook. Allows you to split grid recipe previews into multiple.

public int RecipeGroup

Field Value

int

RequiresTrait

If set only players with given trait can use this recipe

public string RequiresTrait

Field Value

string

Shapeless

Whether the order of input items should be respected

public bool Shapeless

Field Value

bool

ShowInCreatedBy

Used by the handbook. If false, will not appear in the "Created by" section

public bool ShowInCreatedBy

Field Value

bool

Width

Required grid width for crafting this recipe

public int Width

Field Value

int

resolvedIngredients

public GridRecipeIngredient[] resolvedIngredients

Field Value

GridRecipeIngredient[]

Methods

Clone()

Creates a deep copy

public GridRecipe Clone()

Returns

GridRecipe

ConsumeInput(IPlayer, ItemSlot[], int)

Puts the crafted itemstack into the output slot and consumes the required items from the input slots

public bool ConsumeInput(IPlayer byPlayer, ItemSlot[] inputSlots, int gridWidth)

Parameters

byPlayer IPlayer
inputSlots ItemSlot[]
gridWidth int

Returns

bool

FromBytes(BinaryReader, IWorldAccessor)

Deserializes the recipe

public void FromBytes(BinaryReader reader, IWorldAccessor resolver)

Parameters

reader BinaryReader
resolver IWorldAccessor

GenerateOutputStack(ItemSlot[], ItemSlot)

public void GenerateOutputStack(ItemSlot[] inputSlots, ItemSlot outputSlot)

Parameters

inputSlots ItemSlot[]
outputSlot ItemSlot

GetElementInGrid<T>(int, int, T[], int)

public T GetElementInGrid<T>(int row, int col, T[] stacks, int gridwidth)

Parameters

row int
col int
stacks T[]
gridwidth int

Returns

T

Type Parameters

T

GetGridIndex<T>(int, int, T[], int)

public int GetGridIndex<T>(int row, int col, T[] stacks, int gridwidth)

Parameters

row int
col int
stacks T[]
gridwidth int

Returns

int

Type Parameters

T

GetInputStackForPatternCode(string, ItemSlot[])

Returns only the first matching itemstack, there may be multiple

public ItemStack GetInputStackForPatternCode(string patternCode, ItemSlot[] inputSlots)

Parameters

patternCode string
inputSlots ItemSlot[]

Returns

ItemStack

GetNameToCodeMapping(IWorldAccessor)

Resolves Wildcards in the ingredients

public Dictionary<string, string[]> GetNameToCodeMapping(IWorldAccessor world)

Parameters

world IWorldAccessor

Returns

Dictionary<string, string[]>

Matches(IPlayer, ItemSlot[], int)

Check if this recipe matches given ingredients

public bool Matches(IPlayer forPlayer, ItemSlot[] ingredients, int gridWidth)

Parameters

forPlayer IPlayer

The player for trait testing. Can be null.

ingredients ItemSlot[]
gridWidth int

Returns

bool

MatchesAtPosition(int, int, ItemSlot[], int)

public bool MatchesAtPosition(int colStart, int rowStart, ItemSlot[] inputSlots, int gridWidth)

Parameters

colStart int
rowStart int
inputSlots ItemSlot[]
gridWidth int

Returns

bool

ResolveIngredients(IWorldAccessor)

Turns Ingredients into IItemStacks

public bool ResolveIngredients(IWorldAccessor world)

Parameters

world IWorldAccessor

Returns

bool

True on successful resolve

ToBytes(BinaryWriter)

Serialized the recipe

public void ToBytes(BinaryWriter writer)

Parameters

writer BinaryWriter