Class JsonItemStack
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
This is a representation of an item stack in JSON. It resembles a standard in-game item stack but can be stored before the game is loaded.
[ProtoContract]
public class JsonItemStack : IRecipeOutput
- Inheritance
-
JsonItemStack
- Implements
- Inherited Members
- Extension Methods
Examples
"output": {
"type": "item",
"code": "knifeblade-flint",
"stacksize": 1
},
"output": {
"type": "block",
"code": "ladder-wood-north",
"quantity": 3
},
Fields
Attributes
Tree Attributes that should be attached to the resulting itemstack.
[JsonProperty]
[JsonConverter(typeof(JsonAttributesConverter))]
[ProtoMember(4)]
public JsonObject Attributes
Field Value
Code
The asset location code of the block or item.
[ProtoMember(2)]
public AssetLocation Code
Field Value
ResolvedItemstack
The resolved item after conversion.
public ItemStack ResolvedItemstack
Field Value
StackSize
Amount of items in this stacks
[ProtoMember(3)]
public int StackSize
Field Value
Type
Block or Item?
[ProtoMember(1)]
public EnumItemClass Type
Field Value
Properties
Quantity
Alias of StackSize. No real need to use this instead of it.
public int Quantity { get; set; }
Property Value
Methods
Clone()
Creates a deep copy of this object
public JsonItemStack Clone()
Returns
FillPlaceHolder(string, string)
public void FillPlaceHolder(string key, string value)
Parameters
FromBytes(BinaryReader, IClassRegistryAPI)
Loads the ItemStack from the reader.
public virtual void FromBytes(BinaryReader reader, IClassRegistryAPI instancer)
Parameters
reader
BinaryReaderThe reader to get the ItemStack from
instancer
IClassRegistryAPIThe instancer for the ItemStack.
FromString(string)
public static JsonItemStack FromString(string jsonItemstack)
Parameters
jsonItemstack
string
Returns
Matches(IWorldAccessor, ItemStack)
public bool Matches(IWorldAccessor worldForResolve, ItemStack inputStack)
Parameters
worldForResolve
IWorldAccessorinputStack
ItemStack
Returns
Resolve(IWorldAccessor, string, bool)
public bool Resolve(IWorldAccessor resolver, string sourceForErrorLogging, bool printWarningOnError = true)
Parameters
resolver
IWorldAccessorsourceForErrorLogging
stringprintWarningOnError
bool
Returns
Resolve(IWorldAccessor, string, AssetLocation, bool)
Sets itemstack.block or itemstack.item
public bool Resolve(IWorldAccessor resolver, string sourceForErrorLogging, AssetLocation assetLoc, bool printWarningOnError = true)
Parameters
resolver
IWorldAccessorsourceForErrorLogging
stringassetLoc
AssetLocationprintWarningOnError
bool
Returns
ToBytes(BinaryWriter)
Saves the ItemStack to file.
public virtual void ToBytes(BinaryWriter writer)
Parameters
writer
BinaryWriterThe writer to save the item to.