Table of Contents

Class ItemSlot

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

The default item slot to item stacks

public class ItemSlot
Inheritance
ItemSlot
Derived
Inherited Members

Constructors

ItemSlot(InventoryBase)

Create a new instance of an item slot

public ItemSlot(InventoryBase inventory)

Parameters

inventory InventoryBase

Fields

BackgroundIcon

Icon name to be drawn in the slot background

public string BackgroundIcon

Field Value

string

HexBackgroundColor

If set will be used as the background color

public string HexBackgroundColor

Field Value

string

inventory

protected InventoryBase inventory

Field Value

InventoryBase

itemstack

protected ItemStack itemstack

Field Value

ItemStack

Properties

DrawUnavailable

public virtual bool DrawUnavailable { get; set; }

Property Value

bool

Empty

Whether or not the stack is empty.

public virtual bool Empty { get; }

Property Value

bool

Inventory

Gets the inventory attached to this ItemSlot.

public InventoryBase Inventory { get; }

Property Value

InventoryBase

Itemstack

The ItemStack contained within the slot.

public ItemStack Itemstack { get; set; }

Property Value

ItemStack

MaxSlotStackSize

The upper holding limit of the slot itself. Standard slots are only limited by the item stacks maxstack size.

public virtual int MaxSlotStackSize { get; set; }

Property Value

int

StackSize

The number of items in the stack.

public int StackSize { get; }

Property Value

int

StorageType

The storage type of this slot.

public virtual EnumItemStorageFlags StorageType { get; set; }

Property Value

EnumItemStorageFlags

Methods

ActivateSlot(ItemSlot, ref ItemStackMoveOperation)

Called when a player has clicked on this slot. The source slot is the mouse cursor slot. This handles the logic of either taking, putting or exchanging items.

public virtual void ActivateSlot(ItemSlot sourceSlot, ref ItemStackMoveOperation op)

Parameters

sourceSlot ItemSlot
op ItemStackMoveOperation

ActivateSlotLeftClick(ItemSlot, ref ItemStackMoveOperation)

Activates the left click functions of the given slot.

protected virtual void ActivateSlotLeftClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)

Parameters

sourceSlot ItemSlot
op ItemStackMoveOperation

ActivateSlotMiddleClick(ItemSlot, ref ItemStackMoveOperation)

Activates the middle click functions of the given slot.

protected virtual void ActivateSlotMiddleClick(ItemSlot sinkSlot, ref ItemStackMoveOperation op)

Parameters

sinkSlot ItemSlot
op ItemStackMoveOperation

ActivateSlotRightClick(ItemSlot, ref ItemStackMoveOperation)

Activates the right click functions of the given slot.

protected virtual void ActivateSlotRightClick(ItemSlot sourceSlot, ref ItemStackMoveOperation op)

Parameters

sourceSlot ItemSlot
op ItemStackMoveOperation

CanHold(ItemSlot)

Whether or not this slot can hold the item from the source slot.

public virtual bool CanHold(ItemSlot sourceSlot)

Parameters

sourceSlot ItemSlot

Returns

bool

CanTake()

Whether or not this slots item can be retrieved.

public virtual bool CanTake()

Returns

bool

CanTakeFrom(ItemSlot, EnumMergePriority)

Whether or not this slot can take the item from the source slot.

public virtual bool CanTakeFrom(ItemSlot sourceSlot, EnumMergePriority priority = EnumMergePriority.AutoMerge)

Parameters

sourceSlot ItemSlot
priority EnumMergePriority

Returns

bool

FlipWith(ItemSlot)

Forces a flip with the given ItemSlot

protected virtual void FlipWith(ItemSlot withSlot)

Parameters

withSlot ItemSlot

GetRemainingSlotSpace(ItemStack)

Amount of space left, independent of item MaxStacksize

public virtual int GetRemainingSlotSpace(ItemStack forItemstack)

Parameters

forItemstack ItemStack

Returns

int

GetStackDescription(IClientWorldAccessor, bool)

Gets the StackDescription for the item.

public virtual string GetStackDescription(IClientWorldAccessor world, bool extendedDebugInfo)

Parameters

world IClientWorldAccessor

The world the item resides in.

extendedDebugInfo bool

Whether or not we have Extended Debug Info enabled.

Returns

string

GetStackName()

Gets the name of the itemstack- if it exists.

public virtual string GetStackName()

Returns

string

The name of the itemStack or null.

MarkDirty()

Marks the slot as dirty which queues it up for saving and resends it to the clients. Does not sync from client to server.

public virtual void MarkDirty()

OnItemSlotModified(ItemStack)

The event fired when the slot is modified.

public virtual void OnItemSlotModified(ItemStack sinkStack)

Parameters

sinkStack ItemStack

TakeOut(int)

Gets some of the contents of the stack.

public virtual ItemStack TakeOut(int quantity)

Parameters

quantity int

The amount to get from the stack.

Returns

ItemStack

The stack with the quantity take out (or as much as was available)

TakeOutWhole()

Gets the entire contents of the stack, setting the base stack to null.

public virtual ItemStack TakeOutWhole()

Returns

ItemStack

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryFlipWith(ItemSlot)

Attempts to flip the ItemSlots.

public virtual bool TryFlipWith(ItemSlot itemSlot)

Parameters

itemSlot ItemSlot

Returns

bool

Whether or no the flip was successful.

TryPutInto(IWorldAccessor, ItemSlot, int)

Attempts to place item in this slot into the target slot.

public virtual int TryPutInto(IWorldAccessor world, ItemSlot sinkSlot, int quantity = 1)

Parameters

world IWorldAccessor
sinkSlot ItemSlot
quantity int

Returns

int

Amount of moved items

TryPutInto(ItemSlot, ref ItemStackMoveOperation)

Returns the quantity of items that were not merged (left over in the source slot)

public virtual int TryPutInto(ItemSlot sinkSlot, ref ItemStackMoveOperation op)

Parameters

sinkSlot ItemSlot
op ItemStackMoveOperation

Returns

int

Amount of moved items

Events

MarkedDirty

Can be used to interecept marked dirty calls.

public event ActionConsumable MarkedDirty

Event Type

ActionConsumable