Jump to content

How to drag item in inventory


Recommended Posts

Posted

I want to drag around items in inventory, to arrange them for easier clicking.

 

But i cant figure out how to actually drag them to change the place of one item.

 

Inventory does not have any calls for that (or at least i did not find any) and i also tried this:

execute(new ContinualClickMouseEvent(inventory.getMouseDestination(from),new Condition(){
            @Override
            public boolean evaluate() {
                return InventorySlotDestination.getSlot(to).contains(mouse.getPosition());
            }
        }));
        execute(new MoveMouseEvent(inventory.getMouseDestination(to),true));

but all that does is it clicks the item i want to drag and stays there until i force quit the script.

Posted (edited)

This is what I use to swap items in inventory spaces.

	public boolean swapItems(int slot1, int slot2) throws InterruptedException {
		if (getInventory().isItemSelected()) {
			getInventory().deselectItem();
		}
		return getMouse().continualClick(getInventory().getMouseDestination(slot1), new Condition() {
			@Override
			public boolean evaluate() {
				getMouse().move(getInventory().getMouseDestination(slot2), true);
				return getInventory().getMouseDestination(slot2).getBoundingBox().contains(getMouse().getPosition());
			}
		});
	}

Kinda messy, but it works.

Edited by Incus Valley

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