Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question How to make gold bracelets at furnace

Joined
Aug 20, 2020
Messages
1
Hi guys, so I've been working on a gold bracelet making bot. Here is the function used to smelt once the bot has detected a full inventory of gold bars and a mould:

public void execute() {
GameObject furnace = GameObjects.newQuery().within(furnace_area).names("Furnace").results().nearest();
System.out.println(furnace);
if (furnace != null) {
if (furnace.isVisible()) {
furnace.interact("Smelt");
InterfaceComponent makegoldbracelet = Interfaces.getAt(446, 46);
if (makegoldbracelet.click()) {
Execution.delayUntil(() -> Inventory.getQuantity("Gold bracelet") == 27, 30000, 50000);
}

}
}
}
}

I keep getting a null pointed exception which I think is the fact that the makegoldbracelet variable is null until the interface is opened. How do I delay until the furnace interface is open? The bank has the .isOpen() function but I'm not sure how to apply that in this situation.

Many thanks.
 
cuppa.drink(java);
Joined
Mar 13, 2018
Messages
7,464
Crafting uses the makeallinterface, I think? If so you can use MakeAllInterface.isOpen(), along with other MakeAllInterface methods. Generated Documentation (Untitled)

Using your current code, you could probably also do
Code:
if(makegoldbracelet!=null){
     if(makegoldbracelet.click){
//...

A few other minor things: you should nullcheck the return of
Code:
GameObjects.newQuery().within(furnace_area).names("Furnace").results()
it can return null.

also make sure you're only ever going to execute one action per loop, generally. Because right now if furnace is visible, it'll attempt to interact "Smelt" and then also make a gold bracelet. You should restructure this so that if the "makegoldbracelet" is visible, click it, and if not then check if the furnace is visible and if it is then "Smelt" otherwise walk to it.

How do I delay until the furnace interface is open?

Something like
Execution.delayUntil(()-> (makegoldbracelet = Interfaces.getAt(446, 46)) != null , 5000, 7000);


Also join the discord, you'll get more responses.
 
Top