I have experienced Mountain Lion on a Mac mini will go to sleep regardless of the Energy Saver settings in the System Preferences. After some reading, it seems OS X Mountain Lion has very aggressive power management, which will put the system to sleep against your (my) will.
This is my attempt to create a Launch Agent, which will use the system command caffeinate
to prevent sleep indefinitely.
Copy the plist into ~/Library/LaunchAgents
, then, in a Terminal session, run the command to load it up: