I did some modifications on some parts and made some things simpler
I did not test run it though ^^
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep2;
import java.util.Arrays;
import java.util.List;
@ScriptManifest(author = "pupupot", info = "Mines Amethyst crystals and crafts dart tips", name = "Amethyst Minecraft", version = 1.2, logo = "")
public class AmethystMinecraft extends Script {
private final int AMETHYST_X = 3008;
private final List<Integer> AMETHYST_Y = Arrays.asList(9710, 9711, 9712); // Y positions of amethyst crystals
private final String AMETHYST_NAME = "Amethyst";
@Override
public void onStart() {
log("Script started. Let's get this bag.");
}
@Override
public int onLoop() throws InterruptedException {
log("Looking for the purple shit to start mining.");
if (getInventory().getEmptySlots() <= 2) {
craftDartTips();
return 1000;
}
RS2Object amethyst = getObjects().closest(obj ->
obj != null &&
obj.getName().equals("Amethyst crystals") &&
obj.getX() == AMETHYST_X &&
AMETHYST_Y.contains(obj.getY()));
if (amethyst != null) {
if (amethyst.interact("Mine")) {
log("Mining amethyst... Getting this money");
ConditionalSleep2.sleep(240_000, () -> !amethyst.exists() || amethyst.getName().equals("Empty wall"));
}
}
return random(600, 700); // Return a short random delay before the next loop
}
private void craftDartTips() throws InterruptedException {
// Check if chisel and amethyst are in inventory
String CHISEL_NAME = "Chisel";
if (!getInventory().contains(CHISEL_NAME) || !getInventory().contains(AMETHYST_NAME)) {
log("Cannot craft amethyst dart tips. Missing required items.");
return;
}
// Try to get Widget by Text or spellname as the ids can change sometimes, don;t know the widget root, but here is an example
//getWidgets().getWidgetContainingAction(270, "Make");
if (getWidgets().isVisible(270, 17)) {
//Could also press spacebar on keyboard with the Keyboard class
if (getWidgets().interact(270, 17, "Make")) {
ConditionalSleep2.sleep(60_000, () -> !getInventory().contains(AMETHYST_NAME));
}
return;
}
if (!getInventory().isItemSelected()) {
if (getInventory().interact("Use", CHISEL_NAME)) {
ConditionalSleep2.sleep(2500, () -> getInventory().isItemSelected());
}
} else {
if (getInventory().interact("Use", AMETHYST_NAME)) {
ConditionalSleep2.sleep(5_000, () -> getWidgets().isVisible(270, 17));
}
}
}
@Override
public void onExit() {
log("Script stopped. Later Nerd.");
}
}