FushigiBot Posted August 11, 2023 Share Posted August 11, 2023 Can't seem to get this working correctly. The value (groundTinderbox) always seems to come back as 1 no matter how many ground items there are as long as it isn't 0. I'm almost certain it could be because it isn't a stackable item, but not sure. Here is the snippet: public void shouldPickUpTinderboxes() throws InterruptedException { GroundItem groundTinderbox = groundItems.closest(areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf, "Tinderbox"); int emptyInventorySlots = inventory.getEmptySlots(); if (!boolShouldPickUpTinderboxes && !boolShouldSpeakToWiseOldMan && !boolShouldBank && stringMethodSelector.contains("tinderbox_picker") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(myPlayer()) && groundTinderbox != null && groundTinderbox.getAmount() >= emptyInventorySlots) { boolShouldPickUpTinderboxes = true; log("Attempting to pick tinderboxes."); } if (boolShouldPickUpTinderboxes) { if (boolShouldSpeakToWiseOldMan || boolShouldBank || !stringMethodSelector.contains("tinderbox_picker") || !areaDraynorVillageWiseOldMan.contains(myPlayer()) || groundTinderbox.getAmount() == 0 || getInventory().isFull()) { boolShouldPickUpTinderboxes = false; log("Tinderboxes picked."); } } } Quote Link to comment Share on other sites More sharing options...
Gunman Posted August 11, 2023 Share Posted August 11, 2023 @FushigiBot Each item is a separate entity, you probably need to do something like this and use .size() for the amount public List<GroundItem> getAllTinderboxes() { return getGroundItems() .getAll() .stream() .filter(g -> g.getName().equals("Tinderbox") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(g.getPosition()) && getMap().canReach(g)) .collect(Collectors.toList()); } Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted August 11, 2023 Author Share Posted August 11, 2023 15 minutes ago, Gunman said: @FushigiBot Each item is a separate entity, you probably need to do something like this and use .size() for the amount public List<GroundItem> getAllTinderboxes() { return getGroundItems() .getAll() .stream() .filter(g -> g.getName().equals("Tinderbox") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(g.getPosition()) && getMap().canReach(g)) .collect(Collectors.toList()); } Yikes, thanks. Will try that now. Quote Link to comment Share on other sites More sharing options...
FushigiBot Posted August 11, 2023 Author Share Posted August 11, 2023 It worked. Thanks! public void shouldPickUpTinderboxes() throws InterruptedException { List<GroundItem> allTinderboxes = getAllTinderboxes(); int emptyInventorySlots = inventory.getEmptySlots(); if (!boolShouldPickUpTinderboxes && !boolShouldSpeakToWiseOldMan && !boolShouldBank && stringMethodSelector.contains("tinderbox_picker") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(myPlayer()) && !allTinderboxes.isEmpty() && allTinderboxes.size() >= emptyInventorySlots) { boolShouldPickUpTinderboxes = true; log("Attempting to pick tinderboxes."); } if (boolShouldPickUpTinderboxes) { if (boolShouldSpeakToWiseOldMan || boolShouldBank || !stringMethodSelector.contains("tinderbox_picker") || !areaDraynorVillageWiseOldMan.contains(myPlayer()) || allTinderboxes.isEmpty() || getInventory().isFull()) { boolShouldPickUpTinderboxes = false; log("Tinderboxes picked."); } } } public List<GroundItem> getAllTinderboxes() { return getGroundItems() .getAll() .stream() .filter(g -> g.getName().equals("Tinderbox") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(g.getPosition()) && getMap().canReach(g)) .collect(Collectors.toList()); } Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted August 11, 2023 Share Posted August 11, 2023 (edited) 16 hours ago, FushigiBot said: Can't seem to get this working correctly. The value (groundTinderbox) always seems to come back as 1 no matter how many ground items there are as long as it isn't 0. I'm almost certain it could be because it isn't a stackable item, but not sure. Here is the snippet: public void shouldPickUpTinderboxes() throws InterruptedException { GroundItem groundTinderbox = groundItems.closest(areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf, "Tinderbox"); int emptyInventorySlots = inventory.getEmptySlots(); if (!boolShouldPickUpTinderboxes && !boolShouldSpeakToWiseOldMan && !boolShouldBank && stringMethodSelector.contains("tinderbox_picker") && areaDraynorVillageWiseOldManFrontOfTinderboxBookshelf.contains(myPlayer()) && groundTinderbox != null && groundTinderbox.getAmount() >= emptyInventorySlots) { boolShouldPickUpTinderboxes = true; log("Attempting to pick tinderboxes."); } if (boolShouldPickUpTinderboxes) { if (boolShouldSpeakToWiseOldMan || boolShouldBank || !stringMethodSelector.contains("tinderbox_picker") || !areaDraynorVillageWiseOldMan.contains(myPlayer()) || groundTinderbox.getAmount() == 0 || getInventory().isFull()) { boolShouldPickUpTinderboxes = false; log("Tinderboxes picked."); } } } Well the method used here is "groundItems.closest" so you will only get the one that's the closest to the player What gunman said is the perfect solution, just get all and filter out what you need ^^ Edited August 11, 2023 by Khaleesi Quote Link to comment Share on other sites More sharing options...