public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoRandomGroundBlock) {
AIRobotGotoRandomGroundBlock gotoBlock = (AIRobotGotoRandomGroundBlock) ai;
if (gotoBlock.blockFound == null) {
startDelegateAI(new AIRobotGotoSleep(robot));
} else {
startDelegateAI(new AIRobotUseToolOnBlock(robot, gotoBlock.blockFound));
}
} else if (ai instanceof AIRobotSearchBlock) {
AIRobotSearchBlock gotoBlock = (AIRobotSearchBlock) ai;
if (gotoBlock.blockFound != null
&& robot.getRegistry().take(new ResourceIdBlock(gotoBlock.blockFound), robot)) {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
}
blockFound = gotoBlock.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, gotoBlock.path));
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotGotoBlock) {
startDelegateAI(new AIRobotUseToolOnBlock(robot, blockFound));
} else if (ai instanceof AIRobotFetchAndEquipItemStack) {
if (robot.getHeldItem() == null) {
startDelegateAI(new AIRobotGotoSleep(robot));
}
}
}