When do Snow Golems despawn in Minecraft?

I keep a boxed-in Snow Golem in my house. Twice, it has spontaneously vanished. The second time, I was around and I noticed that there was a pile of snowballs, as if it had been killed. However, I am reasonably confident in my house lighting and that there certainly wasn't a mob in the room then.

What exactly can cause snow golems to die?

The only discusssion of spontaneous despawning I could find on Minecraft Wiki clearly does not apply to Snow Golems since they last much longer than one minute.

(Please answer with experimental or code evidence (your own or a link), not just passing on what you've heard. There are a lot of urban legends.)


Solution 1:

Might as well provide an answer based on the source code here.

A snow golem is an EntitySnowman, which inherits its logic from EntityGolem. It will never despawn. (That is, calling canDespawn() on an EntitySnowman always returns false.) So, your snow golem is absolutely not despawning on its own.

Why is it disappearing? That I don't know. If it gets touched by fire, water, rain, or attacked by any other mob, it can easily die. If none of those things are happening, then it probably is some kind of suffocation glitch - maybe it wanders into a block and gets stuck somehow.

Solution 2:

Snow Golems do not de-spawn if the player leaves the area. They'll always be alive, I think, like the wolves.

But you said your 'pet' golem was boxed, them it can't escape that way, but maybe, from a collision bug or a 'glitch', he maybe escaped from some empty corner. Still, he could be teleported, like pet wolves do, and then found a mob, and pursued it forever. (or died)

Or... He just went suicidal. :P