Is there a minecraft command to become immune to damage?
Solution 1:
This command will make you invulnerable to most types of damage for 277 hours:
/effect give PlayerName minecraft:resistance 1000000 255
Additionally, you can become immune to hunger with this:
/effect give PlayerName minecraft:saturation 1000000 255
Not strictly related, but this command will allow you to defeat the ender dragon in one hit:
/effect give PlayerName minecraft:strength 1000000 255