Chris Posted September 6, 2015 Share Posted September 6, 2015 How would I make my character find loot off the minimap? code : GroundItem g = sA.groundItems.closest(c.loot); if (g != null && g.exists()) { if (sA.inventory.isFull()) { sA.inventory.getItem(c.food).interact("Eat"); sA.sleep(2000); } else { g.interact("Take"); sA.sleep(sA.random(1500)); } } Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted September 6, 2015 Share Posted September 6, 2015 (edited) Try something like this: GroundItem g = sA.getGroundItems().getAll().stream().filter(groundItem -> (groundItem.exists() && groundItem.getName().equalsIgnoreCase(c.loot))).min(new Comparator<GroundItem>() { @Override public int compare(GroundItem one, GroundItem two) { return Integer.compare(sA.getMap().distance(one), sA.getMap().distance(two)); } }).orElse(null); if (g == null) return; if (!g.isVisible()) sA.getCamera().toEntity(g); if (sA.getInventory().isFull() && sA.getInventory().contains(c.food)) sA.getInventory().getItem(c.food).interact("Eat"); g.interact("Take"); If that doesn't work, log each line to see where the error is Edited September 6, 2015 by Bobrocket 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted September 6, 2015 Author Share Posted September 6, 2015 Try something like this: GroundItem g = sA.getGroundItems().getAll().stream().filter(groundItem -> (groundItem.exists() && groundItem.getName().equalsIgnoreCase(c.loot))).min(new Comparator<GroundItem>() { @Override public int compare(GroundItem one, GroundItem two) { return Integer.compare(sA.getMap().distance(one), sA.getMap().distance(two)); } }).orElse(null); if (g == null) return; if (!g.isVisible()) sA.getCamera().toEntity(g); if (sA.getInventory().isFull() && sA.getInventory().contains(c.food)) sA.getInventory().getItem(c.food).interact("Eat"); g.interact("Take"); If that doesn't work, log each line to see where the error is ill try this! thanks BR Quote Link to comment Share on other sites More sharing options...