BaseContainer class
public abstract class BaseContainer : IEnumerable<ItemStack>, IEnumerable
In Obsidian.API.
Constructors
public BaseContainer(int size);Properties
CustomName
public ChatMessage CustomName { get; set; }The name the container was given (vanilla's CustomName), shown as its BaseContainer.Title instead of the default one; null when it has none.
Revision
public virtual long Revision { get; }Grows whenever the container's contents change: a slot set, emptied or added to through the container's methods, or a stack it holds changing its count or components (see ChangeStamp). A click remembers it as it arrives, and the server applies the click only if it hasn't moved since, so that the click, and what plugins' handlers decided about it, apply to the contents they saw.
Remarks
Component values are immutable. Assign a replacement through the stack's component indexer, for example stack[food.Type] = food with { Nutrition = 5 }; the slot's revision then advances automatically.
public short Size { get; }public ItemStack this[int index] { get; set; }public ReadOnlySpan<ItemStack> this[Range range] { get; }public ChatMessage Title { get; set; }public InventoryType Type { get; }public Guid Uuid { get; }Viewers
public List<IPlayer> Viewers { get; }The players who have the container open. The server keeps it as they open and close it.
Methods
public virtual int AddItem(ItemStack item);public IEnumerator<ItemStack> GetEnumerator();public virtual ItemStack GetItem(int slot);GetSlot(short)
public virtual SlotDifference GetSlot(short clickedSlot);Gets the slot difference for the given clicked slot.
Parameters
clickedSlot- The slot that was clicked
Returns
A SlotDifference containing the resolved slot and whether it maps to the player's inventory.
Remarks
This method is used to determine the actual slot number for a clicked slot in a container.
public bool HasItems();public virtual bool RemoveItem(int slot);public virtual bool RemoveItem(int slot, int amount);public virtual bool RemoveItem(int slot, int amount, out ItemStack removedItem);public virtual bool RemoveItem(int slot, out ItemStack removedItem);public virtual void Resize(int newSize);public virtual void SetItem(int slot, ItemStack item);Fields
protected ItemStack[] items;