Every time a trap certain mobs, like creepers, zombies, zombie pigman, iron golems, and even regular villagers. ( just as to display them or use in farm) they always disappear. I put them in glass cases with light and no possible way out yet I come back and they are gone. What can I do???? Help!!!
Iron Golems and Villagers do not despawn unless you're playing on a server (servers typically have plugins that outright delete entities to mitigate lag caused by entity buildup in the area and this typically means mobs that normally don't despawn now do). If they go missing then either they found a way out, they glitched through the non-transparent blocks and wandered away to death/freedom, or something on the outside found a way to kill them while trapped inside.
Hostile mobs like creepers, zombies, etc will despawn if you 1)travel more than 128 blocks away (this is immediate), 2)hang out in an area that is 24 to 127 blocks away (random chance of despawn roughly every 30 seconds), and 3)they are not nametagged or holding a picked-up item (if they spawned with it, they can despawn).