How can I prevent mobs from escaping from my mob zoo?
Solution 1:
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.
Solution 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.