IWindow

Represents an instance of a (usually currently open) window/container. This includes double chests, single chests, bot's inventory, etc.

Methods

GetId

Gets the unique ID of the current container sent by the server.

int GetId();

GetWindowType

Returns the type of the current window. The type of the window always starts with "minecraft:" and a list of container types can be found here.

string GetWindowType();

GetWindowName

Returns the title of the current window. This can contain color codes and text effects (e.g.: bold) and therefore IChat is returned. Use window.GetWindowName().GetText() to get the title of the window stripped of color codes and text effects.

IChat GetWindowName();

GetAt

Returns the slot at a given index of this window. The returned ISlot allows you to further interact with the slot (e.g.: drop it, select it, move it). Note: Containers start from index 0 at the top left. EquipmentSlots parameters can only be used on the IInventory container or IPlayerEquipmentSlots.

ISlot GetAt(int index);
ISlot GetAt(EquipmentSlots equipmentSlot);

GetSlots

Returns either all slots for this window if includeEmpty parameter is true, otherwise it will only returns the slots that have an item in them. The returned ISlots allow you to further interact with the slots (e.g.: drop them, move them).

ISlot[] GetSlots(bool includeEmpty = false);

IsOpen

Returns whether this window is currently open.

bool IsOpen();

Close

Attempts to close the current container.

Task Close();

Find

Returns all slot instances which match the given parameters. The parameter allow to both search based on IDs and Metadata, however metadata is optional. Note: Minecraft Block ID's can be found at https://minecraft-ids.grahamedgecombe.com/

ISlot[] Find(ushort id);
ISlot[] Find(ushort[] ids);
ISlot[] Find(ushort id, short metadata);
ISlot[] Find(ushort[] ids, short[] metadata);

FindFirst

Returns the first slot instance which matches the given parameters. The parameter allow to both search based on IDs and Metadata, however metadata is optional. Note: Minecraft Block ID's can be found at https://minecraft-ids.grahamedgecombe.com/ . If the window is the bot's inventory then search will start from the hotbar, whereas all other window searches start from the top left.

ISlot FindFirst(ushort id);
ISlot FindFirst(ushort[] ids);
ISlot FindFirst(ushort id, short metadata);
ISlot FindFirst(ushort[] ids, short[] metadata);

FindByMetadata

Returns all slot instances which match the given Metadata parameter.

    ISlot[] FindByMetadata(short metadata);

FindFirstByMetaData

Returns the first slot instance which match the given Metadata parameter. Note: if the window is the bot's inventory then search will start from the hotbar, whereas all other window searches start from the top left.

ISlot FindFirstByMetadata(short metadata);

FindByType

Finds all slot instances of a given type such as finding all kinds of helmets (diamond, iron, leather, etc) or all kinds of tools (diamond shovel, iron shovel, etc.) You can find the EquipmentType enum here.

ISlot[] FindByType(EquipmentType type);

FindBest

Finds the best tier item of the specified type and returns it's slot. This will look at the material of the item (e.g.: diamond vs iron) and will consider if the item has enchantments, however it will not look at the type of the enchantments. You can find the EquipmentType enum here. You can find the EquipmentSlots enum here.

ISlot FindBest(EquipmentType type);
ISlot FindBest(EquipmentSlots slot);

HasFreeSlots

Returns whether the window has any free (non-occupied) slots. Note: you can also optionally specify how many free slots it must have, by default it is 1.

bool HasFreeSlots(int minSlotCount = 1);

GetFreeSlots

Returns an an array of free (non-occupied) slots. Note: you can optionally specify how many free slots at most it can return, default is 255 which would return all free slots that the window has.

ISlot[] GetFreeSlots(int maxSlotCount = 255);

GetFreeSlot

Attempts to get the first free (non-occupied) slot it can find. Note: if the window is the bot's inventory then search will start from the hotbar, whereas all other window searches start from the top left.

ISlot GetFreeSlot ();

IsEmpty

Returns true if all slots of the window are empty (non-occupied), otherwise false. Note: if the window is the bot's inventory then the armor slots and crafting slots are not taken into account.

bool IsEmpty();

IsFull

Returns true if all slots of the window are taken (occupied), otherwise false. Note: if the window is the bot's inventory then the armor slots and crafting slots are not taken into account.

bool IsFull();

GetAmountOfItem

Returns the amount of a given block ID there are in this window.

int GetAmountOfItem(ushort id);

MouseLeftClick

Attempts to Left click on a slot at the specified index.

Task<bool> MouseLeftClick(int index);

MouseRightClick

Attempts to Right click on a slot at the specified index.

Task<bool> MouseRightClick(int index);

MouseShiftLeftClick

Attempts to Shift + Left click a slot at the specified index.

Task<bool> MouseShiftLeftClick(int index);

MouseMiddleClick

Attempts to middle click a slot at the specified index.

Task<bool> MouseMiddleClick(int index);

ClickHotbarshortcut

Hovers the mouse over a slot, which is at the specified index, and clicks the hotbar shortcut (0-8). This can transfer items from the specified slot into the hotbar or vice-versa. Note: hotbarIndex should be a value between 0 (most left slot) and 8 (most right slot).

Task<bool> ClickHotbarShortcut(int index, int hotbarIndex);

Take

Attempts to transfer items, that match the specified id(s) and where optionalCanBePicked optionally returns true, from the open window to the bot's inventory. You can also optionally specify the max amount of stacks the bot can take in a single function call. Note: this must be called on the window and not the bot's inventory, otherwise an exception will be thrown.

Task<bool> Take(ushort id , int maxStacks = -1, Func<ISlot, bool> optionalCanBePicked = null);
Task<bool> Take(ushort[] ids = null, int maxStacks = -1, Func<ISlot, bool> optionalCanBePicked = null);

Deposit

Attempts to transfer items, that match the specified id(s) and where optionalCanBePicked optionally returns true, from the bot's inventory to the open window. Note: this must be called on the window and not the bot's inventory, otherwise an exception will be thrown.

Task<bool> Deposit(ushort id, Func<ISlot, bool> optionalCanPickSlot = null);
Task<bool> Deposit(ushort[] ids = null, Func<ISlot, bool> optionalCanPickSlot = null);

Last updated