if (interfaces.get(INTERFACE_GRAVE).isValid()) {
atCloseInterface(INTERFACE_GRAVE, INTERFACE_GRAVE_CLOSE);
sleep(500, 800);
}
} else if ((undecidedID = getUndecidedCoffin()) != -1) {
final RSItem item = inventory.getItem(undecidedID);
if (item != null) {
if (item.interact("Check")) {
final long systemTime = System.currentTimeMillis();
while (System.currentTimeMillis() - systemTime < 8000 && !interfaces.get(INTERFACE_COFFIN).isValid()) {
sleep(50, 150);
}
sleep(1200, 2500);
if (interfaces.getComponent(INTERFACE_COFFIN) != null) {
final Integer[] allItems = new Integer[INTERFACE_COFFIN_IDS.length];
final List<Integer> ids = new ArrayList<Integer>();
for (final int index : INTERFACE_COFFIN_IDS) {
ids.add(interfaces.getComponent(INTERFACE_COFFIN, index).getComponentID());
}
ids.toArray(allItems);
boolean found = false;
for (Coffin coffin : coffins) {
if (coffin.doesMatch(allItems)) {
coffin.setCoffinID(undecidedID);
found = true;
break;
}
}
if (!found) {
log("IDs have changed, please alert Timer.");
return -1;
}
}
}
if (interfaces.get(INTERFACE_COFFIN).isValid()) {
atCloseInterface(INTERFACE_COFFIN, INTERFACE_COFFIN_CLOSE);
sleep(500, 800);
}
}
} else {
boolean done = true;
for (Coffin coffin : coffins) {
if (!coffin.set) {
done = false;
final int graveID = getEmptyGrave(coffin.stoneID);
final RSObject grave = objects.getNearest(graveID);
if (grave != null) {
getObjectInView(grave);
final RSItem theCoffin = inventory.getItem(coffin.coffinID);
if (theCoffin != null) {
if (useItem(theCoffin, grave)) {
final long systemTime = System.currentTimeMillis();
while (System.currentTimeMillis() - systemTime < 8000 && !(getMyPlayer().getAnimation() == 827)) {
sleep(50, 150);