Jump to content

All Food Support


Mikey

Recommended Posts

This is an easy way to support all food.

 

Item[] items = myPlayer().getClient().getInventory().getItems();

for (Item i : items) {
    if (i != null && ItemDefinition.forId(i.getId()).getActions()[0] != null) {
        if (ItemDefinition.forId(i.getId()).getActions()[0].equals("Eat")) {
            //this is food
        }
    }
}
Link to comment
Share on other sites

This is an easy way to support all food.

 

Item[] items = myPlayer().getClient().getInventory().getItems();

for (Item i : items) {
    if (i != null && ItemDefinition.forId(i.getId()).getActions()[0] != null) {
        if (ItemDefinition.forId(i.getId()).getActions()[0].equals("Eat")) {
            //this is food
        }
    }
}

There is a way easier way of do thing this.

Link to comment
Share on other sites

This is an easy way to support all food.

 

Item[] items = myPlayer().getClient().getInventory().getItems();

for (Item i : items) {
    if (i != null && ItemDefinition.forId(i.getId()).getActions()[0] != null) {
        if (ItemDefinition.forId(i.getId()).getActions()[0].equals("Eat")) {
            //this is food
        }
    }
}
Instead of myPlayer()#getClient() you can just use client

Why not use item#getItemDefinition()

And the first option might not be the in the first index in the actions array

Not sure but you might want to check it

Link to comment
Share on other sites

Instead of myPlayer()#getClient() you can just use client

Why not use item#getItemDefinition()

And the first option might not be the in the first index in the actions array

Not sure but you might want to check it

 

It always is for food because they're sent through only one packet.

 

Edit: Thanks for the tips by the way.

Edited by Mikey1
Link to comment
Share on other sites

	public int eatFood(int hp) throws InterruptedException	{
		if (client.getSkills().getCurrentLevel(Skill.HITPOINTS) <= hp)	{
			for (Item i: client.getInventory().getItems())	{
				if (i!=null && i.getDefinition().getActions()[0].equalsIgnoreCase("eat"))	{
					client.getInventory().interactWithId(i.getId(), i.getDefinition().getActions()[0], true);
				}
			}
		}
		return 1000;
	}

this method will only work with items that contain the action eat in the first index.

Edited by josedpay
Link to comment
Share on other sites

	public int eatFood(int hp) throws InterruptedException	{
		if (client.getSkills().getCurrentLevel(Skill.HITPOINTS) <= hp)	{
			//check your hp, will only work if your hp is lower or equal to your argument 
			for (Item i: client.getInventory().getItems())	{
				//gets an array of items in your inventory
				if (i!=null && i.getDefinition().getActions()[0].equalsIgnoreCase("eat"))	{
					//check to see if you items arent null, Then look for the item that contains the word eat as the first action, (hence the 0)
					client.getInventory().interactWithId(i.getId(), i.getDefinition().getActions()[0], true);
					//interacts with item: interactWithId(item id, item action, force left click);
				}
			}
		}
		return 1000;
	}

this method will only work with items that contain the action eat in the first index.

 

Are you trying to be funny?

Link to comment
Share on other sites

public int eatFood(int hp) throws InterruptedException	{		if (client.getSkills().getCurrentLevel(Skill.HITPOINTS) <= hp)	{			//check your hp, will only work if your hp is lower or equal to your argument 			for (Item i: client.getInventory().getItems())	{				//gets an array of items in your inventory				if (i!=null && i.getDefinition().getActions()[0].equalsIgnoreCase("eat"))	{					//check to see if you items arent null, Then look for the item that contains the word eat as the first action, (hence the 0)					client.getInventory().interactWithId(i.getId(), i.getDefinition().getActions()[0], true);					//interacts with item: interactWithId(item id, item action, force left click);				}			}		}		return 1000;	}
this method will only work with items that contain the action eat in the first index.
:rolleyes: lol

Not any better than what OP posted

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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