Eat well. Sleep well. Exercise. Dress for success. Socialize, integrate with the team, find the goals that will motivate you - be that helping out your work buddies, or building that sweet new piece of technology.
You want to have energy, health, mood, and motivation. When any of these suffer, your work suffers too.
Don't be afraid to use whatever tools you have at your disposal to cut out distractions and inhibit bad habits, but don't tyrannize yourself either. Working 8 hours straight isn't necessarily your most productive option. Consider scheduling breaks - but use your tools to limit your distractions outside of said breaks. Find a balance that will let you keep your mood up while also getting good work done.