Search in sources :

Example 1 with Item

use of net.runelite.api.Item in project runelite by runelite.

the class RSItemContainerMixin method getItems.

@Inject
@Override
public Item[] getItems() {
    int[] itemIds = getItemIds();
    int[] stackSizes = getStackSizes();
    Item[] items = new Item[itemIds.length];
    for (int i = 0; i < itemIds.length; ++i) {
        RSItem item = client.createItem();
        item.setId(itemIds[i]);
        item.setQuantity(stackSizes[i]);
        items[i] = item;
    }
    return items;
}
Also used : RSItem(net.runelite.rs.api.RSItem) Item(net.runelite.api.Item) RSItem(net.runelite.rs.api.RSItem) Inject(net.runelite.api.mixins.Inject)

Example 2 with Item

use of net.runelite.api.Item in project runelite by runelite.

the class PuzzleSolverOverlay method getItemIds.

private int[] getItemIds(ItemContainer container) {
    int[] itemIds = new int[DIMENSION * DIMENSION];
    Item[] items = container.getItems();
    for (int i = 0; i < items.length; i++) {
        itemIds[i] = items[i].getId();
    }
    // If blank is in the last position, items doesn't contain it, so let's add it manually
    if (itemIds.length > items.length) {
        itemIds[items.length] = BLANK_TILE_VALUE;
    }
    return convertToSolverFormat(itemIds);
}
Also used : Item(net.runelite.api.Item) Point(java.awt.Point)

Example 3 with Item

use of net.runelite.api.Item in project runelite by runelite.

the class BankTagsPlugin method onMenuOptionClicked.

@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event) {
    if (event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId() && event.getMenuAction() == MenuAction.EXAMINE_ITEM_BANK_EQ && event.getId() == EDIT_TAGS_MENU_INDEX) {
        int inventoryIndex = event.getActionParam();
        ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
        if (bankContainer == null) {
            return;
        }
        Item[] items = bankContainer.getItems();
        if (inventoryIndex < 0 || inventoryIndex >= items.length) {
            return;
        }
        Item item = bankContainer.getItems()[inventoryIndex];
        if (item == null) {
            return;
        }
        int itemId = item.getId();
        String itemName = itemManager.getItemComposition(itemId).getName();
        String initialValue = getTags(itemId);
        chatboxInputManager.openInputWindow(itemName + " Tags", initialValue, (newTags) -> {
            if (newTags == null) {
                return;
            }
            setTags(itemId, newTags);
            Widget bankContainerWidget = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
            if (bankContainerWidget == null) {
                return;
            }
            Widget[] bankItemWidgets = bankContainerWidget.getDynamicChildren();
            if (bankItemWidgets == null || inventoryIndex >= bankItemWidgets.length) {
                return;
            }
            Widget bankItemWidget = bankItemWidgets[inventoryIndex];
            String[] actions = bankItemWidget.getActions();
            if (actions == null || EDIT_TAGS_MENU_INDEX - 1 >= actions.length) {
                return;
            }
            int tagCount = getTagCount(itemId);
            actions[EDIT_TAGS_MENU_INDEX - 1] = EDIT_TAGS_MENU_OPTION;
            if (tagCount > 0) {
                actions[EDIT_TAGS_MENU_INDEX - 1] += " (" + tagCount + ")";
            }
        });
    }
}
Also used : ItemContainer(net.runelite.api.ItemContainer) Item(net.runelite.api.Item) Widget(net.runelite.api.widgets.Widget) Subscribe(com.google.common.eventbus.Subscribe)

Example 4 with Item

use of net.runelite.api.Item in project runelite by runelite.

the class ItemPricesOverlay method makeValueTooltip.

private String makeValueTooltip(MenuEntry menuEntry) {
    // Disabling both disables all value tooltips
    if (!config.showGEPrice() && !config.showHAValue()) {
        return null;
    }
    final int widgetId = menuEntry.getParam1();
    ItemContainer container = null;
    // Inventory item
    if (widgetId == INVENTORY_ITEM_WIDGETID || widgetId == BANK_INVENTORY_ITEM_WIDGETID) {
        container = client.getItemContainer(InventoryID.INVENTORY);
    } else // Bank item
    if (widgetId == BANK_ITEM_WIDGETID) {
        container = client.getItemContainer(InventoryID.BANK);
    }
    if (container == null) {
        return null;
    }
    // Find the item in the container to get stack size
    final Item[] items = container.getItems();
    final int index = menuEntry.getParam0();
    if (index < items.length) {
        final Item item = items[index];
        return getItemStackValueText(item);
    }
    return null;
}
Also used : ItemContainer(net.runelite.api.ItemContainer) Item(net.runelite.api.Item)

Example 5 with Item

use of net.runelite.api.Item in project runelite by runelite.

the class PrayerPotion method heals.

@Override
public int heals(Client client) {
    boolean hasHolyWrench = false;
    ItemContainer equipContainer = client.getItemContainer(InventoryID.EQUIPMENT);
    if (equipContainer != null) {
        Item[] equip = equipContainer.getItems();
        hasHolyWrench |= equip.length > RING_SLOT && equip[RING_SLOT].getId() == ItemID.RING_OF_THE_GODS_I;
        if (equip.length > CAPE_SLOT) {
            int cape = equip[CAPE_SLOT].getId();
            hasHolyWrench |= cape == ItemID.PRAYER_CAPE;
            hasHolyWrench |= cape == ItemID.PRAYER_CAPET;
            // No idea what this is
            hasHolyWrench |= cape == ItemID.PRAYER_CAPE_10643;
            hasHolyWrench |= cape == ItemID.MAX_CAPE;
            // Or these
            hasHolyWrench |= cape == ItemID.MAX_CAPE_13282;
            hasHolyWrench |= cape == ItemID.MAX_CAPE_13342;
        }
    }
    if (!hasHolyWrench) {
        ItemContainer invContainer = client.getItemContainer(InventoryID.INVENTORY);
        if (invContainer != null) {
            for (Item itemStack : invContainer.getItems()) {
                int item = itemStack.getId();
                hasHolyWrench |= item == ItemID.HOLY_WRENCH;
                hasHolyWrench |= item == ItemID.PRAYER_CAPE;
                hasHolyWrench |= item == ItemID.PRAYER_CAPET;
                hasHolyWrench |= item == ItemID.PRAYER_CAPE_10643;
                hasHolyWrench |= item == ItemID.MAX_CAPE;
                hasHolyWrench |= item == ItemID.MAX_CAPE_13282;
                hasHolyWrench |= item == ItemID.MAX_CAPE_13342;
                if (hasHolyWrench) {
                    break;
                }
            }
        }
    }
    double perc = hasHolyWrench ? .27 : .25;
    int max = getStat().getMaximum(client);
    return (((int) (max * perc)) * (delta >= 0 ? 1 : -1)) + delta;
}
Also used : ItemContainer(net.runelite.api.ItemContainer) Item(net.runelite.api.Item)

Aggregations

Item (net.runelite.api.Item)10 ItemContainer (net.runelite.api.ItemContainer)3 ItemLayer (net.runelite.api.ItemLayer)3 Node (net.runelite.api.Node)3 Subscribe (com.google.common.eventbus.Subscribe)2 Region (net.runelite.api.Region)2 Tile (net.runelite.api.Tile)2 LocalPoint (net.runelite.api.coords.LocalPoint)2 InventoryItemQuery (net.runelite.api.queries.InventoryItemQuery)2 Widget (net.runelite.api.widgets.Widget)2 EmoteClue (net.runelite.client.plugins.cluescrolls.clues.EmoteClue)2 TextClueScroll (net.runelite.client.plugins.cluescrolls.clues.TextClueScroll)2 Color (java.awt.Color)1 Point (java.awt.Point)1 ItemComposition (net.runelite.api.ItemComposition)1 MenuEntry (net.runelite.api.MenuEntry)1 Player (net.runelite.api.Player)1 Query (net.runelite.api.Query)1 WorldPoint (net.runelite.api.coords.WorldPoint)1 Inject (net.runelite.api.mixins.Inject)1