Welcome!

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

Sign up now!

Resolved Checking if the player is mining.

Joined
Sep 21, 2015
Messages
22
So I'm trying to stop execution while the player is mining, I came up with the following.

Code:
Execution.delayWhile(()->bot.player.getAnimationId() != -1 || bot.player.isMoving(), 2000, 45000);

The issue I'm having is if the player gets through an entire mining cycle and still hasn't mined the ore, the animation starts over which briefly sets the animation id to -1. Does anyone know of a better way to accomplish this, that doesn't spam click the ore?

Ideally I'd be able to check if the ore is still available as well but I don't see such a property on the gameobject (I'm most likely overlooking this).

Edit:

Apparently isValid seems to do the trick, but I'm not sure what is being validated, is it the ore state, the original query for this object?
 
Last edited:
Joined
May 24, 2016
Messages
1,113
Join the slack channel :)

But to answer your question, you could do something like:

Code:
Execution.delayUntil(() -> !rock.isValid, () -> player.getAnimationId() != -1, 3000, 6000);

This will wait until the rock is depleted (isValid), but also check for your animation id and keep checking every 3-6 seconds. So basically if your character stops mining before the rock has depleted, it will break out of the delay.
 
Joined
Dec 31, 2015
Messages
602
Join the slack channel :)

But to answer your question, you could do something like:

Code:
Execution.delayUntil(() -> !rock.isValid, () -> player.getAnimationId() != -1, 3000, 6000);

This will wait until the rock is depleted (isValid), but also check for your animation id and keep checking every 3-6 seconds. So basically if your character stops mining before the rock has depleted, it will break out of the delay.
A delay that large is a big waste of time. Especially when the only other thing you can expect is that the player is moving.

Code:
Execution.delayUntil(() -> !rock.isValid, () -> player.getAnimationId() != -1 || player.isMoving(), 1000, 1200);
 
Joined
Dec 28, 2013
Messages
190
You really shouldn't be halting the bot thread waiting on the ore to get mined as this could potentially take minutes. Doing this can have unintended consequences (such as listeners not firing). Adjust your logic so that the bot can be continually polling at a consistent rate.

Off the top of my head I'd create an AnimationListener (should be simple but if need be I can post the code) and track the time between mining -> no animation -> mining. If it was under a second you know you're still mining. Further optimize by checking the if the rock your player is facing still contains ore.

Iirc you can use object colors to determine if the rock has ore.
 
Joined
Sep 21, 2015
Messages
22
A delay that large is a big waste of time. Especially when the only other thing you can expect is that the player is moving.
I'm aware the only reason I set the timeout that high was because I was testing random method calls with unknown return values and I didn't want the timeout to advance.

Join the slack channel :)
I don't see one anywhere.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
You really shouldn't be halting the bot thread waiting on the ore to get mined as this could potentially take minutes. Doing this can have unintended consequences (such as listeners not firing). Adjust your logic so that the bot can be continually polling at a consistent rate.

Off the top of my head I'd create an AnimationListener (should be simple but if need be I can post the code) and track the time between mining -> no animation -> mining. If it was under a second you know you're still mining. Further optimize by checking the if the rock your player is facing still contains ore.

Iirc you can use object colors to determine if the rock has ore.
The event dispatcher runs on a separate thread. But the point remains that certain ingame circumstances can't be detected which can lead to misbehavior.
 
Joined
Sep 21, 2015
Messages
22
You really shouldn't be halting the bot thread waiting on the ore to get mined as this could potentially take minutes. Doing this can have unintended consequences (such as listeners not firing). Adjust your logic so that the bot can be continually polling at a consistent rate.

Off the top of my head I'd create an AnimationListener (should be simple but if need be I can post the code) and track the time between mining -> no animation -> mining. If it was under a second you know you're still mining. Further optimize by checking the if the rock your player is facing still contains ore.

Iirc you can use object colors to determine if the rock has ore.
This would be fairly easy to do it seems that getting the colors of the object returns a list of colors. I stayed away from that originally because I was unsure how those changed and they were related to the model. The scenario I pictured was my getting the color data for a model that was unloaded and the colors always remaining the same.
 
Joined
May 24, 2016
Messages
1,113
@Guru

It was just an example, eventho I usually use similar delays to not make my bots react close to instantly. I realize it doesn't matter much if you react quickly, but reports do play a huge role and if you are constantly sharp with reactions around other players, it might look suspicous and lead to reports.

9/10 times the !isValid will break out of the delay anyways.

Just my 2cents.
 
Top