Jump to content

Halp :doge:


Recommended Posts

Posted

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));
            }
        }
Posted (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 smile.png

Edited by Bobrocket
  • Like 1
Posted

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 smile.png

ill try this! thanks BR

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...