I just loaded up my most recent save in Minecraft, and I appear to be underground, inside some rocks. I've seen this before a couple times (eg, the bug when exiting a cart), or when under falling sand. I'm quickly losing health, and in the couple of seconds that the game has been loaded, I haven't seen anything but the grey rock texture. I've tried jumping and moving to no avail.
Is there a way to respawn without losing everything I'm carrying with me? Is there anything that I need to do to prevent this from happening again?
