Java Code Examples for net.runelite.api.ItemContainer#getItem()
The following examples show how to use
net.runelite.api.ItemContainer#getItem() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpecialCounterPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private SpecialWeapon usedSpecialWeapon() { ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT); if (equipment == null) { return null; } Item weapon = equipment.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx()); if (weapon == null) { return null; } for (SpecialWeapon specialWeapon : SpecialWeapon.values()) { if (specialWeapon.getItemID() == weapon.getId()) { return specialWeapon; } } return null; }
Example 2
Source File: CastleWarsBandage.java From plugins with GNU General Public License v3.0 | 6 votes |
private boolean hasBracelet(ItemContainer equipmentContainer) { if (equipmentContainer == null) { return false; } final Item gloves = equipmentContainer.getItem(EquipmentInventorySlot.GLOVES.getSlotIdx()); if (gloves != null) { return BRACELETS.contains(gloves.getId()); } return false; }
Example 3
Source File: SpecialCounterPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private SpecialWeapon usedSpecialWeapon() { ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT); if (equipment == null) { return null; } Item weapon = equipment.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx()); if (weapon == null) { return null; } for (SpecialWeapon specialWeapon : SpecialWeapon.values()) { if (specialWeapon.getItemID() == weapon.getId()) { return specialWeapon; } } return null; }
Example 4
Source File: CastleWarsBandage.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private boolean hasBracelet(ItemContainer equipmentContainer) { if (equipmentContainer == null) { return false; } final Item gloves = equipmentContainer.getItem(EquipmentInventorySlot.GLOVES.getSlotIdx()); if (gloves != null) { return BRACELETS.contains(gloves.getId()); } return false; }
Example 5
Source File: ItemPricesOverlay.java From plugins with GNU General Public License v3.0 | 5 votes |
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 || widgetId == EXPLORERS_RING_ITEM_WIDGETID) { container = client.getItemContainer(InventoryID.INVENTORY); } // Bank item else 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 int index = menuEntry.getParam0(); final Item item = container.getItem(index); if (item != null) { return getItemStackValueText(item); } return null; }
Example 6
Source File: TimersPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
/** * Remove SOTD timer and update stamina timer when equipment is changed. */ @Subscribe void onItemContainerChanged(ItemContainerChanged itemContainerChanged) { if (itemContainerChanged.getContainerId() != InventoryID.EQUIPMENT.getId()) { return; } ItemContainer container = itemContainerChanged.getItemContainer(); Item weapon = container.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx()); if (weapon == null || (weapon.getId() != ItemID.STAFF_OF_THE_DEAD && weapon.getId() != ItemID.TOXIC_STAFF_OF_THE_DEAD && weapon.getId() != ItemID.STAFF_OF_LIGHT && weapon.getId() != ItemID.TOXIC_STAFF_UNCHARGED)) { // remove sotd timer if the staff has been unwielded removeGameTimer(STAFF_OF_THE_DEAD); } if (wasWearingEndurance) { Item ring = container.getItem(EquipmentInventorySlot.RING.getSlotIdx()); // when using the last ring charge the ring changes to the uncharged version, ignore that and don't // halve the timer if (ring == null || (ring.getId() != ItemID.RING_OF_ENDURANCE && ring.getId() != ItemID.RING_OF_ENDURANCE_UNCHARGED_24844)) { wasWearingEndurance = false; if (staminaTimer != null) { // Remaining duration gets divided by 2 Duration remainingDuration = Duration.between(Instant.now(), staminaTimer.getEndTime()).dividedBy(2); // This relies on the chat message to be removed, which could be after the timer has been culled; // so check there is still remaining time if (!remainingDuration.isNegative() && !remainingDuration.isZero()) { log.debug("Halving stamina timer"); staminaTimer.setDuration(remainingDuration); } } } } }
Example 7
Source File: ItemStatOverlay.java From plugins with GNU General Public License v3.0 | 4 votes |
@VisibleForTesting String buildStatBonusString(ItemStats s) { ItemStats other = null; final ItemEquipmentStats currentEquipment = s.getEquipment(); ItemContainer c = client.getItemContainer(InventoryID.EQUIPMENT); if (s.isEquipable() && currentEquipment != null && c != null) { final int slot = currentEquipment.getSlot(); final Item item = c.getItem(slot); if (item != null) { other = itemManager.getItemStats(item.getId(), false); } if (other == null && slot == EquipmentInventorySlot.WEAPON.getSlotIdx()) { // Unarmed other = UNARMED; } } final ItemStats subtracted = s.subtract(other); final ItemEquipmentStats e = subtracted.getEquipment(); final StringBuilder b = new StringBuilder(); if (config.showWeight()) { double sw = config.alwaysShowBaseStats() ? subtracted.getWeight() : s.getWeight(); b.append(buildStatRow("Weight", s.getWeight(), sw, true, false, s.isEquipable())); } if (subtracted.isEquipable() && e != null) { b.append(buildStatRow("Prayer", currentEquipment.getPrayer(), e.getPrayer(), false, false)); b.append(buildStatRow("Speed", currentEquipment.getAspeed(), e.getAspeed(), true, false)); b.append(buildStatRow("Melee Str", currentEquipment.getStr(), e.getStr(), false, false)); b.append(buildStatRow("Range Str", currentEquipment.getRstr(), e.getRstr(), false, false)); b.append(buildStatRow("Magic Dmg", currentEquipment.getMdmg(), e.getMdmg(), false, true)); final StringBuilder abb = new StringBuilder(); abb.append(buildStatRow("Stab", currentEquipment.getAstab(), e.getAstab(), false, false)); abb.append(buildStatRow("Slash", currentEquipment.getAslash(), e.getAslash(), false, false)); abb.append(buildStatRow("Crush", currentEquipment.getAcrush(), e.getAcrush(), false, false)); abb.append(buildStatRow("Magic", currentEquipment.getAmagic(), e.getAmagic(), false, false)); abb.append(buildStatRow("Range", currentEquipment.getArange(), e.getArange(), false, false)); if (abb.length() > 0) { b.append(ColorUtil.wrapWithColorTag("Attack Bonus</br>", JagexColors.MENU_TARGET)).append(abb); } final StringBuilder dbb = new StringBuilder(); dbb.append(buildStatRow("Stab", currentEquipment.getDstab(), e.getDstab(), false, false)); dbb.append(buildStatRow("Slash", currentEquipment.getDslash(), e.getDslash(), false, false)); dbb.append(buildStatRow("Crush", currentEquipment.getDcrush(), e.getDcrush(), false, false)); dbb.append(buildStatRow("Magic", currentEquipment.getDmagic(), e.getDmagic(), false, false)); dbb.append(buildStatRow("Range", currentEquipment.getDrange(), e.getDrange(), false, false)); if (dbb.length() > 0) { b.append(ColorUtil.wrapWithColorTag("Defence Bonus</br>", JagexColors.MENU_TARGET)).append(dbb); } } return b.toString(); }
Example 8
Source File: TimersPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
/** * Remove SOTD timer and update stamina timer when equipment is changed. */ @Subscribe public void onItemContainerChanged(ItemContainerChanged itemContainerChanged) { if (itemContainerChanged.getContainerId() != InventoryID.EQUIPMENT.getId()) { return; } ItemContainer container = itemContainerChanged.getItemContainer(); Item weapon = container.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx()); if (weapon == null || (weapon.getId() != ItemID.STAFF_OF_THE_DEAD && weapon.getId() != ItemID.TOXIC_STAFF_OF_THE_DEAD && weapon.getId() != ItemID.STAFF_OF_LIGHT && weapon.getId() != ItemID.TOXIC_STAFF_UNCHARGED)) { // remove sotd timer if the staff has been unwielded removeGameTimer(STAFF_OF_THE_DEAD); } if (wasWearingEndurance) { Item ring = container.getItem(EquipmentInventorySlot.RING.getSlotIdx()); // when using the last ring charge the ring changes to the uncharged version, ignore that and don't // halve the timer if (ring == null || (ring.getId() != ItemID.RING_OF_ENDURANCE && ring.getId() != ItemID.RING_OF_ENDURANCE_UNCHARGED_24844)) { wasWearingEndurance = false; if (staminaTimer != null) { // Remaining duration gets divided by 2 Duration remainingDuration = Duration.between(Instant.now(), staminaTimer.getEndTime()).dividedBy(2); // This relies on the chat message to be removed, which could be after the timer has been culled; // so check there is still remaining time if (!remainingDuration.isNegative() && !remainingDuration.isZero()) { log.debug("Halving stamina timer"); staminaTimer.setDuration(remainingDuration); } } } } }
Example 9
Source File: ItemPricesOverlay.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
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 || widgetId == EXPLORERS_RING_ITEM_WIDGETID || widgetId == SEED_VAULT_INVENTORY_ITEM_WIDGETID) { container = client.getItemContainer(InventoryID.INVENTORY); } // Bank item else if (widgetId == BANK_ITEM_WIDGETID) { container = client.getItemContainer(InventoryID.BANK); } // Seed vault item else if (widgetId == SEED_VAULT_ITEM_WIDGETID) { container = client.getItemContainer(InventoryID.SEED_VAULT); } if (container == null) { return null; } // Find the item in the container to get stack size final int index = menuEntry.getParam0(); final Item item = container.getItem(index); if (item != null) { return getItemStackValueText(item); } return null; }
Example 10
Source File: ItemStatOverlay.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@VisibleForTesting String buildStatBonusString(ItemStats s) { ItemStats other = null; final ItemEquipmentStats currentEquipment = s.getEquipment(); ItemContainer c = client.getItemContainer(InventoryID.EQUIPMENT); if (s.isEquipable() && currentEquipment != null && c != null) { final int slot = currentEquipment.getSlot(); final Item item = c.getItem(slot); if (item != null) { other = itemManager.getItemStats(item.getId(), false); } if (other == null && slot == EquipmentInventorySlot.WEAPON.getSlotIdx()) { // Unarmed other = UNARMED; } } final ItemStats subtracted = s.subtract(other); final ItemEquipmentStats e = subtracted.getEquipment(); final StringBuilder b = new StringBuilder(); if (config.showWeight()) { double sw = config.alwaysShowBaseStats() ? subtracted.getWeight() : s.getWeight(); b.append(buildStatRow("Weight", s.getWeight(), sw, true, false, s.isEquipable())); } if (subtracted.isEquipable() && e != null) { b.append(buildStatRow("Prayer", currentEquipment.getPrayer(), e.getPrayer(), false, false)); b.append(buildStatRow("Speed", currentEquipment.getAspeed(), e.getAspeed(), true, false)); b.append(buildStatRow("Melee Str", currentEquipment.getStr(), e.getStr(), false, false)); b.append(buildStatRow("Range Str", currentEquipment.getRstr(), e.getRstr(), false, false)); b.append(buildStatRow("Magic Dmg", currentEquipment.getMdmg(), e.getMdmg(), false, true)); final StringBuilder abb = new StringBuilder(); abb.append(buildStatRow("Stab", currentEquipment.getAstab(), e.getAstab(), false, false)); abb.append(buildStatRow("Slash", currentEquipment.getAslash(), e.getAslash(), false, false)); abb.append(buildStatRow("Crush", currentEquipment.getAcrush(), e.getAcrush(), false, false)); abb.append(buildStatRow("Magic", currentEquipment.getAmagic(), e.getAmagic(), false, false)); abb.append(buildStatRow("Range", currentEquipment.getArange(), e.getArange(), false, false)); if (abb.length() > 0) { b.append(ColorUtil.wrapWithColorTag("Attack Bonus</br>", JagexColors.MENU_TARGET)).append(abb); } final StringBuilder dbb = new StringBuilder(); dbb.append(buildStatRow("Stab", currentEquipment.getDstab(), e.getDstab(), false, false)); dbb.append(buildStatRow("Slash", currentEquipment.getDslash(), e.getDslash(), false, false)); dbb.append(buildStatRow("Crush", currentEquipment.getDcrush(), e.getDcrush(), false, false)); dbb.append(buildStatRow("Magic", currentEquipment.getDmagic(), e.getDmagic(), false, false)); dbb.append(buildStatRow("Range", currentEquipment.getDrange(), e.getDrange(), false, false)); if (dbb.length() > 0) { b.append(ColorUtil.wrapWithColorTag("Defence Bonus</br>", JagexColors.MENU_TARGET)).append(dbb); } } return b.toString(); }
Example 11
Source File: PrayerPotion.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override public int heals(Client client) { boolean hasHolyWrench = false; ItemContainer equipContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (equipContainer != null) { Item cape = equipContainer.getItem(CAPE_SLOT); Item ring = equipContainer.getItem(RING_SLOT); hasHolyWrench = ring != null && ring.getId() == ItemID.RING_OF_THE_GODS_I; if (cape != null) { int capeId = cape.getId(); hasHolyWrench |= capeId == ItemID.PRAYER_CAPE; hasHolyWrench |= capeId == ItemID.PRAYER_CAPET; hasHolyWrench |= capeId == ItemID.PRAYER_CAPE_10643; // No idea what this is hasHolyWrench |= capeId == ItemID.MAX_CAPE; hasHolyWrench |= capeId == ItemID.MAX_CAPE_13282; // Or these hasHolyWrench |= capeId == 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 percent = hasHolyWrench ? perc + .02 : perc; int max = getStat().getMaximum(client); return (((int) (max * percent)) * (delta >= 0 ? 1 : -1)) + delta; }