From fbc5ca9688a5980694a3b59ef7cd4426d359eccc Mon Sep 17 00:00:00 2001 From: JKetelaar Date: Wed, 29 Oct 2014 10:53:41 +0100 Subject: [PATCH] Added Inventory#getItem and Inventory#combine --- src/org/rev317/min/api/methods/Inventory.java | 43 +++++++++++++++++++ src/org/rev317/min/api/methods/Menu.java | 6 +++ 2 files changed, 49 insertions(+) diff --git a/src/org/rev317/min/api/methods/Inventory.java b/src/org/rev317/min/api/methods/Inventory.java index d847b4d..fa25c2e 100644 --- a/src/org/rev317/min/api/methods/Inventory.java +++ b/src/org/rev317/min/api/methods/Inventory.java @@ -2,6 +2,7 @@ package org.rev317.min.api.methods; import org.parabot.environment.api.utils.Filter; import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.SleepCondition; import org.rev317.min.Loader; import org.rev317.min.accessors.Interface; import org.rev317.min.api.wrappers.Item; @@ -199,5 +200,47 @@ public class Inventory { return getCount(id) > 0; } + public static Item getItem(int id){ + for (Item i : getItems(id)){ + if (i != null){ + return i; + } + } + return null; + } + + public static boolean combine(int itemOne, int itemTwo) { + Item io = getItem(itemOne); + Item it = getItem(itemTwo); + + if (io != null) { + if (it != null) { + Menu.interact(io, "use"); + Time.sleep(50, 100); + Menu.interact(it, "use with"); + Time.sleep(50, 100); + return true; + } + } + return false; + } + + public static boolean combine(int itemOne, int itemTwo, SleepCondition sleepCondition) { + Item io = getItem(itemOne); + Item it = getItem(itemTwo); + + if (io != null) { + if (it != null) { + Menu.interact(io, "use"); + Time.sleep(50, 100); + Menu.interact(it, "use with"); + Time.sleep(50, 100); + if (sleepCondition.isValid()) { + return true; + } + } + } + return false; + } } diff --git a/src/org/rev317/min/api/methods/Menu.java b/src/org/rev317/min/api/methods/Menu.java index f3be6d6..6cf0504 100644 --- a/src/org/rev317/min/api/methods/Menu.java +++ b/src/org/rev317/min/api/methods/Menu.java @@ -182,6 +182,12 @@ public class Menu { case "cancel": actionId = 1107; break; + case "wear": + actionId = 454; + break; + case "use with": + actionId = 870; + break; } sendAction(actionId, item.getSlot(), item.getId(), 3214); }