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. Open in GitHub
[DocumentAsJson]
[ProtoContract]
public class JsonItemStack : IRecipeOutput, IByteSerializable, IConcreteCloneable<JsonItemStack>, ICloneable
- 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)]
[DocumentAsJson("Optional", "None", false)]
public JsonObject? Attributes
Field Value
Code
The asset location code of the block or item.
[ProtoMember(2)]
[DocumentAsJson("Required", "", false)]
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)]
[DocumentAsJson("Optional", "1", false)]
public int StackSize
Field Value
Type
Block or Item?
[ProtoMember(1)]
[DocumentAsJson("Recommended", "Block", false)]
public EnumItemClass Type
Field Value
Properties
Quantity
Alias of StackSize. No real need to use this instead of it.
[DocumentAsJson("Optional", "1", false)]
public int Quantity { get; set; }
Property Value
ResolvedItemStack
Was added for interface.
Field 'ResolvedItemstack' is left for compatibility reasons
public ItemStack? ResolvedItemStack { get; set; }
Property Value
Methods
Clone()
Creates a deep copy of this object
public virtual JsonItemStack Clone()
Returns
CloneTo(object)
protected virtual void CloneTo(object stack)
Parameters
stackobject
FillPlaceHolder(string, string)
public virtual 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
readerBinaryReaderThe reader to get the ItemStack from
instancerIClassRegistryAPIThe instancer for the ItemStack.
FromBytes(BinaryReader, IWorldAccessor)
Loads the ItemStack from the reader.
public virtual void FromBytes(BinaryReader reader, IWorldAccessor resolver)
Parameters
readerBinaryReaderresolverIWorldAccessor
FromString(string)
public static JsonItemStack? FromString(string jsonItemstack)
Parameters
jsonItemstackstring
Returns
Matches(IWorldAccessor, ItemStack)
public virtual bool Matches(IWorldAccessor worldForResolve, ItemStack inputStack)
Parameters
worldForResolveIWorldAccessorinputStackItemStack
Returns
Resolve(IWorldAccessor, string)
public virtual bool Resolve(IWorldAccessor world, string sourceForErrorLogging)
Parameters
worldIWorldAccessorsourceForErrorLoggingstring
Returns
Resolve(IWorldAccessor, string, bool)
public bool Resolve(IWorldAccessor resolver, string sourceForErrorLogging, bool printWarningOnError)
Parameters
resolverIWorldAccessorsourceForErrorLoggingstringprintWarningOnErrorbool
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
resolverIWorldAccessorsourceForErrorLoggingstringassetLocAssetLocationprintWarningOnErrorbool
Returns
ToBytes(BinaryWriter)
Saves the ItemStack to file.
public virtual void ToBytes(BinaryWriter writer)
Parameters
writerBinaryWriterThe writer to save the item to.