Mikey Posted April 11, 2014 Posted April 11, 2014 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 } } }
Joseph Posted April 11, 2014 Posted April 11, 2014 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.
Mikey Posted April 11, 2014 Author Posted April 11, 2014 There is a way easier way of do thing this. Why not post it?
Cyro Posted April 11, 2014 Posted April 11, 2014 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 clientWhy 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
Mikey Posted April 12, 2014 Author Posted April 12, 2014 (edited) 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 April 12, 2014 by Mikey1
Joseph Posted April 12, 2014 Posted April 12, 2014 It always is for food because they're sent through only one packet. Edit: Thanks for the tips by the way. Oh because I was on my phone at the time and I still am. But I'll post it tomorrow. I was also going to tell you those tips too
Joseph Posted April 13, 2014 Posted April 13, 2014 (edited) 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 April 21, 2014 by josedpay
Pseudo Posted April 13, 2014 Posted April 13, 2014 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?
Dog_ Posted April 13, 2014 Posted April 13, 2014 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. lolNot any better than what OP posted
Swizzbeat Posted April 13, 2014 Posted April 13, 2014 for (Item current : client.getInventory().getItems()) { if (Arrays.asList(current.getDefinition().getActions()).contains("Eat")) { client.getInventory().interactWithId(current.getId(), "Eat"); } } pls
Pseudo Posted April 14, 2014 Posted April 14, 2014 for (Item current : client.getInventory().getItems()) { if (Arrays.asList(current.getDefinition().getActions()).contains("Eat")) { client.getInventory().interactWithId(current.getId(), "Eat"); } } pls Null check pls Ant.
Swizzbeat Posted April 14, 2014 Posted April 14, 2014 Null check pls Ant.No I like seeing stack traces it makes me feel sophisticated Corey with an e. 1
NotoriousPP Posted April 14, 2014 Posted April 14, 2014 No I like seeing stack traces it makes me feel sophisticated Corey with an e. Wait.... Stack traces are a bad thing?! 1
Swizzbeat Posted April 14, 2014 Posted April 14, 2014 Wait.... Stack traces are a bad thing?! Only if it's an NPE ;)