Simulating the Cosmic Gas: From Globular Clusters to the Most Massive Haloes