Jump to content

Need help dragging item in inventory


Recommended Posts

Posted (edited)

I'm sure I'm just not doing something right. Pretty much just trying to drag a knife to the last inventory slot.
 

public int onLoop() throws InterruptedException {
        if(inventory.contains("Knife")){
            if(inventory.getSlot("Knife") == inventory.getSlot(27)){
                log("We're good.");
            } else {
                MoveKnife();
            }
        }
        return 602;
    }


void MoveKnife() {
        boolean isInPosition = false;
        mouse.continualClick(inventory.getMouseDestination(inventory.getSlot("Knife")), new Condition() {
            @Override
            public boolean evaluate() {
                return isInPosition == true;
            }
        });
        mouse.move(inventory.getMouseDestination(27));
        isInPosition = true;
    }

 

I get a compile error 'local variables referenced from an inner class must be final or effectively final' when building because I'm trying to change isInPosition after moving the mouse. But even if I remove that, all that is happening is the mouse is going click down on the knife and is not moving at all after that. Any help would be appreciated.

Edited by Alakazizam
  • Alakazizam changed the title to Need help dragging item in inventory
Posted
1 hour ago, Alakazizam said:

I'm sure I'm just not doing something right. Pretty much just trying to drag a knife to the last inventory slot.
 

public int onLoop() throws InterruptedException {
        if(inventory.contains("Knife")){
            if(inventory.getSlot("Knife") == inventory.getSlot(27)){
                log("We're good.");
            } else {
                MoveKnife();
            }
        }
        return 602;
    }


void MoveKnife() {
        boolean isInPosition = false;
        mouse.continualClick(inventory.getMouseDestination(inventory.getSlot("Knife")), new Condition() {
            @Override
            public boolean evaluate() {
                return isInPosition == true;
            }
        });
        mouse.move(inventory.getMouseDestination(27));
        isInPosition = true;
    }

 

I get a compile error 'local variables referenced from an inner class must be final or effectively final' when building because I'm trying to change isInPosition after moving the mouse. But even if I remove that, all that is happening is the mouse is going click down on the knife and is not moving at all after that. Any help would be appreciated.

try

	    InventorySlotDestination currItemDestination = new InventorySlotDestination(bot, currentSlot);
            InventorySlotDestination placementDestination = new InventorySlotDestination(bot, mapSlot);

            if (currentSlot != mapSlot) {
                if (bot.getMethods().getMouse().continualClick(currItemDestination, new Condition() {
                    @Override
                    public boolean evaluate() {
                        return bot.getMethods().getMouse().move(placementDestination) && placementDestination.evaluate();
                    }
                })) {
                    //sleep or do something after?
                }
            }

This is an example from my code I use to sort my inventory using a map of items. this is how I get it to drag items around

So mapSlot would be slot 27?

  • Like 1

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