public boolean checkIfMiningSmokingRock() {
if (myPlayer().isAnimating()) {
RS2Object rock;
Position myPosition = myPlayer().getPosition();
switch (myPlayer().getRotation()) {
case 0: //SOUTH
rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() - 1, 0));
break;
case 511:
case 512: //WEST
case 513:
rock = getRockAtPosition(new Position(myPosition.getX() - 1, myPosition.getY(), 0));
break;
case 1023:
case 1024: //NORTH
case 1025:
rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() + 1, 0));
break;
case 1535:
case 1536: //EAST
case 1537:
rock = getRockAtPosition(new Position(myPosition.getX() + 1, myPosition.getY(), 0));
break;
}
return rock != null && !arrayContainsPrimitiveInt(MINABLE_ROCK_ID_ARRAY, rock.getId()); //method is not needed if the rock id's are stored in a list, #contains() would work fine
}
return false;
}
private RS2Object getRockAtPosition(Position position) {
for (RS2Object current : client.getCurrentRegion().getObjects()) {
if (current != null && current.getName().contains("Rock") && position.equals(current.getPosition())) {
return current;
}
}
return null;
}
private boolean arrayContainsPrimitiveInt(int[] array, int integer) {
for (int current : array) {
if (current == integer)
return true;
}
return false;
}
FYI switch statement looks like that because when mining you're rotation isn't "exactly" what it's supposed to be and may be off by +- 1. This should give people a good idea on how to implement smoking rock detection into their own mining scripts.