Class ItemSlot
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
The default item slot to item stacks
public class ItemSlot
- Inheritance
-
ItemSlot
- Derived
- Inherited Members
- Extension Methods
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
HexBackgroundColor
If set will be used as the background color
public string HexBackgroundColor
Field Value
inventory
protected InventoryBase inventory
Field Value
itemstack
protected ItemStack itemstack
Field Value
Properties
DrawUnavailable
public virtual bool DrawUnavailable { get; set; }
Property Value
Empty
Whether or not the stack is empty.
public virtual bool Empty { get; }
Property Value
Inventory
Gets the inventory attached to this ItemSlot.
public InventoryBase Inventory { get; }
Property Value
Itemstack
The ItemStack contained within the slot.
public ItemStack Itemstack { get; set; }
Property Value
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
StackSize
The number of items in the stack.
public int StackSize { get; }
Property Value
StorageType
The storage type of this slot.
public virtual EnumItemStorageFlags StorageType { get; set; }
Property Value
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
ItemSlotop
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
ItemSlotop
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
ItemSlotop
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
ItemSlotop
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
CanTake()
Whether or not this slots item can be retrieved.
public virtual bool CanTake()
Returns
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
ItemSlotpriority
EnumMergePriority
Returns
FlipWith(ItemSlot)
Forces a flip with the given ItemSlot
protected virtual void FlipWith(ItemSlot withSlot)
Parameters
withSlot
ItemSlot
GetBestSuitedSlot(ItemSlot, ItemStackMoveOperation, List<ItemSlot>)
public virtual WeightedSlot GetBestSuitedSlot(ItemSlot sourceSlot, ItemStackMoveOperation op = null, List<ItemSlot> skipSlots = null)
Parameters
sourceSlot
ItemSlotop
ItemStackMoveOperationskipSlots
List<ItemSlot>
Returns
GetRemainingSlotSpace(ItemStack)
Amount of space left, independent of item MaxStacksize
public virtual int GetRemainingSlotSpace(ItemStack forItemstack)
Parameters
forItemstack
ItemStack
Returns
GetStackDescription(IClientWorldAccessor, bool)
Gets the StackDescription for the item.
public virtual string GetStackDescription(IClientWorldAccessor world, bool extendedDebugInfo)
Parameters
world
IClientWorldAccessorThe world the item resides in.
extendedDebugInfo
boolWhether or not we have Extended Debug Info enabled.
Returns
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
intThe 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
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
IWorldAccessorsinkSlot
ItemSlotquantity
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
ItemSlotop
ItemStackMoveOperation
Returns
- int
Amount of moved items
Events
MarkedDirty
Can be used to interecept marked dirty calls.
public event ActionConsumable MarkedDirty