SPECTATOR
Spectator mode is designed for spectating things. In it, you will take no damage from anything, not even types that bypass invulnerability, and you can fly through walls. You cannot interact with anything in the world, including breaking and placing blocks, attacking entities, and opening containers.