net.runelite.api.ItemContainer Java Examples
The following examples show how to use
net.runelite.api.ItemContainer.
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: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateBraceletOfSlaughterCharges(final int value) { config.slaughter(value); if (config.showInfoboxes() && config.showSlayerBracelets()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, itemContainer.getItems()); } }
Example #2
Source File: ItemChargePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void updateDodgyNecklaceCharges(final int value) { config.dodgyNecklace(value); if (config.showInfoboxes() && config.showDodgyCount()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, itemContainer.getItems()); } }
Example #3
Source File: ItemChargePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void updateBindingNecklaceCharges(final int value) { config.bindingNecklace(value); if (config.showInfoboxes() && config.showBindingNecklaceCharges()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, itemContainer.getItems()); } }
Example #4
Source File: ItemChargePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void updateAmuletOfChemistryCharges(final int value) { config.amuletOfChemistry(value); if (config.showInfoboxes() && config.showAmuletOfChemistryCharges()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, itemContainer.getItems()); } }
Example #5
Source File: ThreeStepCrypticClue.java From plugins with GNU General Public License v3.0 | 6 votes |
private boolean checkForPart(final ItemContainer itemContainer, int clueScrollPart, int index) { // If we have the part then that step is done if (itemContainer.contains(clueScrollPart)) { final Map.Entry<CrypticClue, Boolean> entry = clueSteps.get(index); if (!entry.getValue()) { entry.setValue(true); return true; } } return false; }
Example #6
Source File: ItemChargePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void updateRingOfForgingCharges(final int value) { config.ringOfForging(value); if (config.showInfoboxes() && config.showRingOfForgingCount()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, itemContainer.getItems()); } }
Example #7
Source File: PrayerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onItemContainerChanged(final ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); final ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); final ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT); if (container == inventory || container == equipment) { doseOverlay.setHasHolyWrench(false); doseOverlay.setHasPrayerRestore(false); doseOverlay.setBonusPrayer(0); if (inventory != null) { checkContainerForPrayer(inventory.getItems()); } if (equipment != null) { prayerBonus = checkContainerForPrayer(equipment.getItems()); } } }
Example #8
Source File: BankPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private Item[] getBankTabItems() { final ItemContainer container = client.getItemContainer(InventoryID.BANK); if (container == null) { return null; } final Item[] items = container.getItems(); int currentTab = client.getVar(Varbits.CURRENT_BANK_TAB); if (currentTab > 0) { int startIndex = 0; for (int i = currentTab - 1; i > 0; i--) { startIndex += client.getVar(TAB_VARBITS.get(i - 1)); } int itemCount = client.getVar(TAB_VARBITS.get(currentTab - 1)); return Arrays.copyOfRange(items, startIndex, startIndex + itemCount); } return items; }
Example #9
Source File: MaxHitPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateMaxHitWidget() { Widget equipmentStats = client.getWidget(WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER); ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT); Item[] equipedItems = new Item[14]; if (equipmentStats != null && !equipmentStats.isHidden()) { if (equipmentContainer != null) { equipedItems = equipmentContainer.getItems(); } MeleeMaxHitCalculator meleeMaxHitCalculator = new MeleeMaxHitCalculator(this.client, equipedItems); RangeMaxHitCalculator rangeMaxHitCalculator = new RangeMaxHitCalculator(this.client, equipedItems); MagicMaxHitCalculator magicMaxHitCalculator = new MagicMaxHitCalculator(this.client, equipedItems); MaxHit maxHit = new MaxHit(meleeMaxHitCalculator.getMaxHit(), rangeMaxHitCalculator.getMaxHit(), magicMaxHitCalculator.getMaxHit()); this.setWidgetMaxHit(maxHit); } }
Example #10
Source File: ZalcanoUtil.java From plugins with GNU General Public License v3.0 | 6 votes |
/** * Courtesy of OP * * @param itemId * @return */ int countStackInInventory(int itemId) { ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); if (inventory != null) { Item[] items = inventory.getItems(); for (int i = 0; i < 28; ++i) { if (i < items.length) { Item item = items[i]; if (item.getId() >= 0 && item.getId() == itemId) { return item.getQuantity(); } } } } return 0; }
Example #11
Source File: LootTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void processInventoryLoot(String event, LootRecordType lootRecordType, ItemContainer inventoryContainer, Collection<ItemStack> groundItems) { if (inventorySnapshot != null) { Multiset<Integer> currentInventory = HashMultiset.create(); Arrays.stream(inventoryContainer.getItems()) .forEach(item -> currentInventory.add(item.getId(), item.getQuantity())); groundItems.stream() .forEach(item -> currentInventory.add(item.getId(), item.getQuantity())); final Multiset<Integer> diff = Multisets.difference(currentInventory, inventorySnapshot); List<ItemStack> items = diff.entrySet().stream() .map(e -> new ItemStack(e.getElement(), e.getCount(), client.getLocalPlayer().getLocalLocation())) .collect(Collectors.toList()); addLoot(event, -1, lootRecordType, items); inventorySnapshot = null; } }
Example #12
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 #13
Source File: KourendLibraryPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updatePlayerBooks() { ItemContainer itemContainer = client.getItemContainer(InventoryID.INVENTORY); EnumSet<Book> books = EnumSet.noneOf(Book.class); if (itemContainer != null) { for (Item item : itemContainer.getItems()) { Book book = Book.byId(item.getId()); if (book != null) { books.add(book); } } } playerBooks = books; }
Example #14
Source File: GraveyardRoom.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { if (!inside()) { return; } ItemContainer container = event.getItemContainer(); if (container == client.getItemContainer(InventoryID.INVENTORY)) { this.score = score(container.getItems()); if (counter == null) { BufferedImage image = itemManager.getImage(ANIMALS_BONES); counter = new GraveyardCounter(image, plugin); infoBoxManager.addInfoBox(counter); } counter.setCount(score); } }
Example #15
Source File: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateDodgyNecklaceCharges(final int value) { config.dodgyNecklace(value); if (config.showInfoboxes() && config.showDodgyCount()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, itemContainer.getItems()); } }
Example #16
Source File: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateAmuletOfChemistryCharges(final int value) { config.amuletOfChemistry(value); if (config.showInfoboxes() && config.showAmuletOfChemistryCharges()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, itemContainer.getItems()); } }
Example #17
Source File: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateExpeditiousCharges(final int value) { config.expeditious(value); if (config.showInfoboxes() && config.showSlayerBracelets()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, itemContainer.getItems()); } }
Example #18
Source File: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateAmuletOfBountyCharges(final int value) { config.amuletOfBounty(value); if (config.showInfoboxes() && config.showAmuletOfBountyCharges()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, itemContainer.getItems()); } }
Example #19
Source File: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateBindingNecklaceCharges(final int value) { config.bindingNecklace(value); if (config.showInfoboxes() && config.showBindingNecklaceCharges()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, itemContainer.getItems()); } }
Example #20
Source File: ThreeStepCrypticClue.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private boolean checkForPart(final ItemContainer itemContainer, int clueScrollPart, int index) { // If we have the part then that step is done if (itemContainer.contains(clueScrollPart)) { final Map.Entry<CrypticClue, Boolean> entry = clueSteps.get(index); if (!entry.getValue()) { entry.setValue(true); return true; } } return false; }
Example #21
Source File: ItemChargePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
private void updateRingOfForgingCharges(final int value) { config.ringOfForging(value); if (config.showInfoboxes() && config.showRingOfForgingCount()) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); if (itemContainer == null) { return; } updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, itemContainer.getItems()); } }
Example #22
Source File: PrayerPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe private void onItemContainerChanged(final ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); final ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); final ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT); if (container != null && (container.equals(inventory) || container.equals(equipment))) { doseOverlay.setHasHolyWrench(false); doseOverlay.setHasPrayerRestore(false); doseOverlay.setBonusPrayer(0); if (inventory != null) { checkContainerForPrayer(inventory.getItems()); } if (equipment != null) { prayerBonus = checkContainerForPrayer(equipment.getItems()); } } }
Example #23
Source File: GraveyardRoom.java From plugins with GNU General Public License v3.0 | 6 votes |
private void onItemContainerChanged(ItemContainerChanged event) { if (!inside()) { return; } ItemContainer container = event.getItemContainer(); if (container == client.getItemContainer(InventoryID.INVENTORY)) { int score = score(container.getItems()); if (counter == null) { BufferedImage image = itemManager.getImage(ANIMALS_BONES); counter = new GraveyardCounter(image, plugin); infoBoxManager.addInfoBox(counter); } counter.setCount(score); } }
Example #24
Source File: BankPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private Multiset<Integer> getBankItemSet() { ItemContainer itemContainer = client.getItemContainer(InventoryID.BANK); if (itemContainer == null) { return HashMultiset.create(); } Multiset<Integer> set = HashMultiset.create(); for (Item item : itemContainer.getItems()) { if (item.getId() != ItemID.BANK_FILLER) { set.add(item.getId(), item.getQuantity()); } } return set; }
Example #25
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 #26
Source File: BankPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private Item[] getBankTabItems() { final ItemContainer container = client.getItemContainer(InventoryID.BANK); if (container == null) { return null; } final Item[] items = container.getItems(); int currentTab = client.getVar(Varbits.CURRENT_BANK_TAB); if (currentTab > 0) { int startIndex = 0; for (int i = currentTab - 1; i > 0; i--) { startIndex += client.getVar(TAB_VARBITS.get(i - 1)); } int itemCount = client.getVar(TAB_VARBITS.get(currentTab - 1)); return Arrays.copyOfRange(items, startIndex, startIndex + itemCount); } return items; }
Example #27
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 #28
Source File: MotherlodePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (!inMlm || !shouldUpdateOres || inventorySnapshot == null || container != client.getItemContainer(InventoryID.INVENTORY)) { return; } // Build set of current inventory Multiset<Integer> current = HashMultiset.create(); Arrays.stream(container.getItems()) .filter(item -> MLM_ORE_TYPES.contains(item.getId())) .forEach(item -> current.add(item.getId(), item.getQuantity())); // Take the difference Multiset<Integer> delta = Multisets.difference(current, inventorySnapshot); // Update the session delta.forEachEntry(session::updateOreFound); inventorySnapshot = null; shouldUpdateOres = false; }
Example #29
Source File: LootTrackerPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
/** * Takes a snapshot of the local player's inventory and equipment right before respawn. */ private void deathInventorySnapshot() { final ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); final ItemContainer equipment = client.getItemContainer(InventoryID.EQUIPMENT); inventorySnapshot = HashMultiset.create(); if (inventory != null) { Arrays.stream(inventory.getItems()) .forEach(item -> inventorySnapshot.add(item.getId(), item.getQuantity())); } if (equipment != null) { Arrays.stream(equipment.getItems()) .forEach(item -> inventorySnapshot.add(item.getId(), item.getQuantity())); } }
Example #30
Source File: MotherlodePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe void onVarbitChanged(VarbitChanged event) { if (inMlm) { int lastSackValue = curSackSize; refreshSackValues(); shouldUpdateOres = curSackSize < lastSackValue; if (shouldUpdateOres) { // Take a snapshot of the inventory before the new ore is added. ItemContainer itemContainer = client.getItemContainer(InventoryID.INVENTORY); if (itemContainer != null) { inventorySnapshot = HashMultiset.create(); Arrays.stream(itemContainer.getItems()) .filter(item -> MLM_ORE_TYPES.contains(item.getId())) .forEach(item -> inventorySnapshot.add(item.getId(), item.getQuantity())); } } } }