Jump to content

Need help dragging item in inventory


Alakazizam

Recommended Posts

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
Link to comment
Share on other sites

  • Alakazizam changed the title to Need help dragging item in inventory
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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