ISlot

Represents an instance of a slot.

Note: A lot of inventory functions usually have a bool to indicate the tasks success or failure, as the server can reject these actions.

Methods

HasNbt

Returns true if the slot has NBT data, otherwise false. NBT data can store such information as enchantments, the title (custom name) of the item, etc. You do not have to access the NBT variable manually, instead functions like GetName(), HasEnchantment(), etc should be used instead.

bool HasNbt();

GetName

Returns the title (custom name) of the item. Can be null if there is no NBT data and the item was not renamed by the server/anvil.

string GetName();

GetLore

Returns the lore (description) of the item from the NBT data, if there is no NBT data then null is returned.

string GetLore();

HasEnchantment

Returns true if the Item has an enchantment with a given id, otherwise false. You can find the enchantment id list here.

bool HasEnchantment(int id);

GetEnchantmentLevel

Returns the enchantment level on this item by enchantment id. You can find the enchantment id list here. Note: returns -1 if the item does not have an enchantment with the specified id.

int GetEnchantmentLevel(int id);

GetEnchantments

Returns an array of all enchantments on the item. The enchantment class contains the id and level of the enchantment.

Enchantment[] GetEnchantments();

GetNBT (legacy)

Returns a string representation of the NBT data.

string GetNBT();

IsEmpty

Returns true if the slot is empty (non-occupied), otherwise false.

bool IsEmpty();

IsStackFull

Returns true if the item stack is full, otherwise false.

bool IsStackFull();

IsStackable

Returns true if the item is stackable, otherwise false.

bool IsStackable();

DropStack

Attempts to drop the entire stack, returns true if this was successful, otherwise false.

Task<bool> DropStack();

Drop

Attempts to drop a single item (1 out of 64) from the item stack. Returns true if successful, otherwise false.

Task<bool> Drop();

Eat

Attempts to eat the Item. Returns true if successful, otherwise false.

Task<bool> Eat();

Select

Attempts to select (bring to to hotbar and select) the item from this slot. Returns true if successful, otherwise false.

Task<bool> Select();

Use

Attempts to use (bring to hotbar, select, and right click it) the item from this slot. Returns true if successful, otherwise false.

Task<bool> Use();

Transfer

Attempts to transfer the item to another slot. Returns true if successful, otherwise false.

Task<bool> Transfer(ISlot other);

DepositTo

Attempts to deposit an item to the specified window. Returns true if successful, otherwise false. You can optionally specify a specific slot index that the item should be placed at using the index parameter. If the index is not specified then it will place the item in the first available slot.

Task<bool> DepositTo(IWindow window, sbyte index = -1);

BringToHotbar

Attempts to bring the item to the hotbar. Returns true if successful, otherwise false. You can optionally specify a hotbar slot index (0-8). If the slot index is not specified then it will place it in the first available slot or the currently selected slot.

Task<bool> BringToHotbar(sbyte optionalSlotIndex = -1);

IsWearable

Returns true if the item is wearable (e.g.: armor).

bool IsWearable();

PutOn

Attempts to put on (equip) the item. Returns true if successful, otherwise false.

Task<bool> PutOn();

TakeOff

Attempts to take off (unequip) the item. Returns true if successful, otherwise false.

Task<bool> TakeOff();

Last updated