Ok so for this function:
@Override
public boolean canProcess() throws InterruptedException {
return script.getGroundItems().closest(GroundID) != null && script.getGroundItems().closest(GroundID).isOnScreen();
//script.getGroundItems().closest(GroundID).isVisible() ;
}
You are loading a new item 2 times, if you would be walking it could be loading different items or even return Null on the isOnScreen method. + You should check in here if your inventory is full or not.
A better way is to load it once and check on it. is this
@Override
public boolean canProcess() throws InterruptedException {
if(script.getInvenotry().isFull){
return false;
}
grountItem item = script.getGroundItems().closest(GroundID);
return item != null && item.isOnScreen();
}
__________________________________________________________________________________________________________________________________________________________________
For the next Part:
@Override
public void process() throws InterruptedException {
script.currentState = Status.LOOTING;
GroundItem loot = script.getGroundItems().closest(GroundID);
//if (GroundID != null && !script.getInventory().isFull())
if (!script.inventory.isFull()){
loot.interact("Take");
sleep(random(999,1777));
}
}
You are not Null checking if there is loot on the ground. (Commented out)
Also move the inventory check to canProcess, else it might get stuck in trying to loot but your inventory is full so it will never loot.
@Override
public void process() throws InterruptedException {
script.currentState = Status.LOOTING;
GroundItem loot = script.getGroundItems().closest(GroundID);
if (loot != null){
loot.interact("Take");
sleep(random(999,1777));
}
}
Try to consider using Conditional sleeps instead of a random sleep.
This might click the loot multiple times for no reason.
You could do this instead:
@Override
public void process() throws InterruptedException {
script.currentState = Status.LOOTING;
GroundItem loot = script.getGroundItems().closest(GroundID);
if (loot != null){
if(loot.interact("Take")){
int prevAmount = script.getInventory().getAmount(loot.getName());
new ConditionalSleep(random(5000, 7500)) {
@Override
public boolean condition() throws InterruptedException {
return script.getInventory().getAmount(loot.getName()) > prevAmount;
}
}.sleep();
}
}
}
I Hope this helped you ^^