I am trying to use some fish on a fire in order to cook it, and it works if nothing is in the way, but with an NPC over an RS2Object it doesn't and so the functions need to be improved:
public void interactInventoryEntity(EEntities e1, EEntities e2, EAction action, EAnimations sleepingAnimation) {
if (!widgetHandler.isTabOpen(Tab.INVENTORY)) {
widgetHandler.openTab(Tab.INVENTORY);
}
if (inventoryHandler.containsByIndex(e1)) {
t1 = inventoryHandler.interactItem(e1, action);
if (t1) {
t1 = false;
t2 = entityHandler.getRS2Object(e2.getEntityIndex()).interact();
}
if (t2) {
t2 = false;
CSleep.sleepUntil(() -> script.myPlayer().getAnimation() == sleepingAnimation.getAnimationId(), 4000);
CSleep.sleepUntil(() -> script.myPlayer().getAnimation() == -1, 9000);
}
}
}
The interact function is from the api, and the entityHandler function is this:
public RS2Object getRS2Object(int id){
return script.getObjects().closest(id);
}
Then I pass the fire entity to the function
FIRE("Fire", 26185),
interactInventoryEntity(EEntities.FISH, EEntities.FIRE, EAction.INTERACTION_USE, EAnimations.ANIMATION_COOKING_ON_FIRE);
So it selects the fish okay, clicks on the NPC instead of selecting the fire and then sleeps for 4 seconds Does interact() without parameters always left click?