KingBo Posted June 3, 2021 Share Posted June 3, 2021 Hey guys, so I've got this bit where the bot drinks wines but I want it to drop the jugs directly after drinking. if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) { log("Drinking"); getInventory().interact("Drink", "Jug of wine"); if (getInventory().contains("Jug")) { log("Dropping"); getInventory().interact("Drop", "Jug"); This is what I've got so far but it only works sometimes other times it just ignores the jug after drinking. What would be a better way to do this? Quote Link to comment Share on other sites More sharing options...
Heiz Posted June 3, 2021 Share Posted June 3, 2021 (edited) Always put a sleep and an if conditional after an action: if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) { log("Drinking"); if(getInventory().interact("Drink", "Jug of wine")){ Sleep.sleepUntil(() -> getInventory().contains("Jug"), 2400, 1200); if (getInventory().contains("Jug")) { log("Dropping"); if(getInventory().interact("Drop", "Jug")){ Sleep.sleepUntil(() -> (!getInventory().contains("Jug")), 2400, 1200); } } } } Get this Sleep with Lambda expressions here: Edited June 3, 2021 by Heiz Quote Link to comment Share on other sites More sharing options...
Abysm Posted June 3, 2021 Share Posted June 3, 2021 You could also do it the other way around. First check if you have any jugs in the inventory, then drop them. After than you have the condition for jug of wine in inventory and health percentage -> drink 2 Quote Link to comment Share on other sites More sharing options...
Gunman Posted June 3, 2021 Share Posted June 3, 2021 3 hours ago, KingBo said: if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) { log("Drinking"); getInventory().interact("Drink", "Jug of wine"); if (getInventory().contains("Jug")) { log("Dropping"); getInventory().interact("Drop", "Jug"); Always try to keep it 1 interaction per cycle of the onLoop. So to do that here you can do as the guy said above by reversing the order. if (getInventory().contains("Jug")) { log("Dropping"); if (getInventory().dropAll("Jug")) { ConditionalSleep2.sleep(1200, ()-> !getInventory().contains("Jug")); } } else if (getInventory().contains("Jug of wine") && myPlayer().getHealthPercent() <= 60) { log("Drinking"); if (getInventory().interact("Drink", "Jug of wine")) { //Depends on your needs but you can sleep or not here ConditionalSleep2.sleep(1200, ()-> myPlayer().getHealthPercent() > 60); } } But if you want it purely done after drinking then you will have to do it Heiz way or put the check and dropping of "Jug" at the top of your onLoop. P.S. 3 hours ago, KingBo said: This is what I've got so far but it only works sometimes other times it just ignores the jug after drinking. What would be a better way to do this? Reason it ignores the Jug btw is because every game tick is ~600ms, so when you drank the wine you were also checking for Jug on the same game tick. It would take a game tick for the game to make the wine go from Jug of wine to Jug. Quote Link to comment Share on other sites More sharing options...