Table of Contents

Interface IItemStack

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

Represents a stack of items or blocks

public interface IItemStack
Extension Methods

Properties

Attributes

Attributes assigned to this itemstack. Modifiable.

ITreeAttribute Attributes { get; set; }

Property Value

ITreeAttribute

Block

The Block if ItemClass==Block, otherwise null

Block Block { get; }

Property Value

Block

Class

Is it a Block or Item?

EnumItemClass Class { get; }

Property Value

EnumItemClass

Collectible

The base class the Item/Block inherits from

CollectibleObject Collectible { get; }

Property Value

CollectibleObject

Id

The items or blocks unique id

int Id { get; }

Property Value

int

Item

The Item if ItemClass==Item, otherwise null

Item Item { get; }

Property Value

Item

StackSize

Amount of items or blocks in this stack

int StackSize { get; set; }

Property Value

int

Methods

Clone()

Creates a deep copy of the itemstack

ItemStack Clone()

Returns

ItemStack

Equals(IWorldAccessor, ItemStack, params string[])

Checks if this item stack is of the same class, id and has the same stack attributes. Ignores stack size

bool Equals(IWorldAccessor worldForResolve, ItemStack sourceStack, params string[] ignoreAttributeSubTrees)

Parameters

worldForResolve IWorldAccessor
sourceStack ItemStack
ignoreAttributeSubTrees string[]

Returns

bool

FromBytes(BinaryReader)

Deserializes an itemstack from given byte stream

void FromBytes(BinaryReader stream)

Parameters

stream BinaryReader

GetDescription(IWorldAccessor, ItemSlot, bool)

Returns a multiline description text of the item

string GetDescription(IWorldAccessor world, ItemSlot inSlot, bool debug = false)

Parameters

world IWorldAccessor
inSlot ItemSlot
debug bool

Whether to show additional debug info

Returns

string

GetName()

Returns the name displayed in the players inventory

string GetName()

Returns

string

MatchesSearchText(IWorldAccessor, string)

Checks if the contained item or block name contains given searchtext

bool MatchesSearchText(IWorldAccessor world, string searchText)

Parameters

world IWorldAccessor
searchText string

Returns

bool

ToBytes(BinaryWriter)

Serializes this itemstack into a byte stream

void ToBytes(BinaryWriter stream)

Parameters

stream BinaryWriter