EDIT: Thanks to @HeyImJamie and @Explv for pointing out that this was much more complicated than necessary. This snippet accomplishes the same but more efficiently and reliably than my own method:
RS2Object furnace = objects.closest("Furnace");
if(getInventory().interact("Use", "Item") && getObjects().closest("Furnace") != null && getObjects().closest("Furnace").interact("Use")) {
//Do things here
}
-----
While working on a script, I noticed that calling entity.interact() to use an object on an entity, such as in the case of using an item on a furnace to open the crafting interface, would occasionally (for me, more often than not) click on players standing in front of the furnace, rather than on the furnace itself. Although the method was clicking inside the furnace, players standing in front of the furnace would take priority, and I would end up using my item on the player standing in front of the furnace, resulting in a "Nothing interesting happens." message. I solved this problem using the following snippet:
RS2Object furnace = objects.closest("Furnace");
if (!furnace.isVisible())
camera.toEntity(furnace);
furnace.hover();
sleep(random(100, 500));
if(mouse.getEntitiesOnCursor().size() == 1 && mouse.getEntitiesOnCursor().get(0).equals(furnace)) {
mouse.click(false);
//Do things here
}
This simply moves the mouse over the furnace, then checks if the furnace is the only thing under the mouse. If this is true, then it will interact with the furnace, and then continue normally. If not, this cycle of the loop will be complete, and the next cycle will move the mouse once more and check again. This method has proven successful over many hours of testing my script, and has completely eliminated the "Nothing interesting happens." message.