if (ai instanceof AIRobotSearchBlock) {
AIRobotSearchBlock searchAI = (AIRobotSearchBlock) ai;
if (searchAI.blockFound != null
&& RobotRegistry.getRegistry(robot.worldObj).take(
new ResourceIdBlock(searchAI.blockFound), robot)) {
if (blockFound != null) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
}
blockFound = searchAI.blockFound;
startDelegateAI(new AIRobotGotoBlock(robot, searchAI.path));
} else {
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotGotoBlock) {
AIRobotGotoBlock gotoBlock = (AIRobotGotoBlock) ai;
startDelegateAI(new AIRobotUseToolOnBlock(robot, blockFound));
} else if (ai instanceof AIRobotFetchAndEquipItemStack) {
if (robot.getHeldItem() == null) {
startDelegateAI(new AIRobotGotoSleep(robot));
}
} else if (ai instanceof AIRobotUseToolOnBlock) {
robot.getRegistry().release(new ResourceIdBlock(blockFound));
blockFound = null;
}
}