How can I stop mobs from despawning?

I am using Spigot, some plugins, and I want to make like a zoo on a map, with mobs behind glass cubes. The problem is that when I load my map, every time some of the mobs just vanish, empty cages. I put eggs again, they spawn, I go to my other map in the multiverse (/mv tp my_other_map
) and when I come back, empty cages again, always the same ones...
I've read it's a question of distance of me (distance in cubes unit), if I'm too far away, the mobs will despawn... Is there a way for them to stay?
Best Answer
Just as an extra option to colorfusion's solution: putting a name tag on a mob will prevent them from despawning as if they were a tamed animal like a cow or chicken. This obviously does not work if the difficulty is set to peaceful as that will despawn the mobs,
Pictures about "How can I stop mobs from despawning?"



Why do my mobs keep Despawning?
Mobs subject to despawning In most cases, a mob will despawn immediately if there are no players within a distance of 128 blocks. If it's not within 32 blocks of a player for more than 30 seconds, there's a 1\u2044800 chance each game tick it will despawn (2.47% chance per second).Do leads stop mobs from Despawning?
You may have mob spawning disabled in your Multiverse world. If you have Multiverse installed on your server then it's possible that mob spawning has been disabled for your entire world.Why are mobs not Despawning?
Theoretically, any mob with armor or holding an object within the spawn chunks will never despawn, due to the spawn chunks being in memory at all time.Minecraft How To STOP Mobs From Despawning Tutorial
More answers regarding how can I stop mobs from despawning?
Answer 2
option 1 they dont have gravity option 2 they cannot move 18 blocks above or they will instantly disappear when they are too far option 3 like Gnarly 404 said get them nametags
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Karolina Grabowska, Name Name, SHVETS production, SHVETS production