How can I prevent mobs from escaping from my mob zoo?
My monster mob zoo is failing; I can't keep them from teleporting out. The photo shown is not one I have taken but it demonstrates what I am trying to do:

How do I keep my mobs from teleporting through glass? Note that I am using the PC version and am in creative mode.
Best Answer
As @Unionhawk said, your mobs are almost certainly de-spawning. This means they vanish from the world forever, like footprints in the sand. But as time goes by new mobs spawn, such is the circle of life.
In order to have a proper 'zoo' of mobs, you need to stop them de-spawning. In the case of Zombies, (as @MrLemon pointed out) simply throwing an item at them and letting them pick it up is enough to keep them spawned. However this only works for Zombies.
Thankfully, as of 1.6.1, there is an item designed to both name mobs and keep them spawned for good - the name tag. Name tags can be found naturally within chests that spawn in dungeons or (as of 1.7.2) by fishing.
If you're in creative you can pull one straight from the creative inventory, and if you have access to console commands (i.e. you allowed them in map options when creating the map) you can use this command:
/give <player> 421 <amount>
Where <player> is replaced with your minecraft name and <amount> is replaced by the number of items you want. For example I would type:
/give Pharap 421 1
which would give me a single name tag.
Alternatively (as pointed out by @SaintWacko) you can avoid specifying your name by typing this instead:
/give @p 421 1
Also note that an enderman is the only mob naturally capable of teleporting, thus even after naming one it is still capable of escaping. Also note that name tags do not stop mobs from dying, so try not to suffocate them or set any on fire.
Pictures about "How can I prevent mobs from escaping from my mob zoo?"



How do you keep mobs from disappearing?
Name tags. Perhaps the best way to keep mobs from despawning is through the use of name tags. These items are rare and can be difficult to find, but naming mobs with a name tag is the most surefire way to ensure that they will never despawn.What blocks can mobs not walk through?
Most mobs cannot see through most solid blocks, including semi-transparent blocks such as ice, glass, tall grass, or glass panes. Mobs do not attempt to walk on rail tracks unless pushed onto the rails by other mobs.How do you keep mobs in place?
And a wall or a fence will help tremendously in keeping mobs from wandering randomly into your territory, provided they're tall enough that they can't jump over.MINECRAFT | How to Keep Mobs from Spawning in Your House!! 1.16.4
More answers regarding how can I prevent mobs from escaping from my mob zoo?
Answer 2
It seems likely that you're not getting teleporting behavior out of your mobs. What you are more likely getting is pack-spawn behavior.
If you google "minecraft pack spawn" you'll get a hit on this page. Here's a quote from that site:
For each spawning cycle, one attempt is made to spawn a pack of mobs in each eligible chunk. A random location in the chunk is chosen to be the center point of the pack. For the pack to spawn at all, the center block must be water for water mobs and air for all other mobs. Note that in the latter case, it must actually be an air block. Any other block, even a non-colliding one, will prevent the entire pack from spawning. If the pack location is suitable, 12 attempts are made to spawn up to 4 mobs (8 for Wolves, 1 for Ghasts) within a 41×1×41 area centered at that block (that's a 41×41 square that is one block high). Mobs will spawn with the lowest part of their body inside this area. For each spawn attempt, a block location within the pack area is chosen at random. Though the pack area extends 21 blocks out from the center, the random location is heavily skewed toward the center of the pack. Approximately 85% of spawns will be within 5 blocks of the pack center, and 99% within 10 blocks of the center.
Now for a human-readable version of that information.
If your "cage" has spawnable space in it, then the pack spawn can result in mobs spawning within 10 blocks of that location, provided they are also valid spawnable space. (Also of note - the area surrounding the cage would need to be at the same y-level to result in pack spawning.)
That link above will also help you understand what constitutes spawnable space, but for your purposes you can probably think of it as a light-level issue. If you press F3 and look at the "bl:" part, that shows your the light level for the place you are currently standing. If that number is 7 or below, then the place you are standing is likely a valid spawn location. (There are other things to consider, but I'm assuming you are standing there and you are not on a slab.)
Essentially you have 2 or 3 options to avoid escaping attractions in your park;
- Light everything up above light level 7 (note: will not stop passive mobs from spawning)
- Place your "cages" at a different y level than everything else in the area.
- Otherwise make all surrounding space within 10 blocks (at the y-level of your cage floor) unspawnable.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Geometric Photography, Brett Sayles, Brett Sayles, Geometric Photography
