Forum: gaming.stackexchange.com
Tags: <minecraft-java-edition>
Title: Can passive mobs spawn underground?
Question: There's a rumour that passive mobs (pigs, cows, sheep) can only spawn on the highest solid block. In other words, they won't spawn on grass with a solid block roof over it, such as in an underground cave, a player-built barn, or a glass dome.  Is this true, as of Minecraft 1.0?

Answers:
sents: text: I'm no expert at Java, so this isn't a decisive answer, but I figure it can't hurt to post the code here anyway for others to decipher.
text: From SpawnerAnimals.java : (Comments mine) private static boolean canCreatureTypeSpawnAtLocation(EnumCreatureType enumcreaturetype, World world, int i, int j, int k) { if(enumcreaturetype.getCreatureMaterial() == Material.water) //
text: If it's a water creature... { return world.getBlockMaterial(i, j, k).getIsLiquid() && !
text: world.isBlockNormalCube(i, j + 1, k); //
text: Make sure it spawns in water } else { return world.isBlockNormalCube(i, j - 1, k) && !
text: world.isBlockNormalCube(i, j, k) && !
text: world.getBlockMaterial(i, j, k).getIsLiquid() && !
text: world.isBlockNormalCube(i, j + 1, k); //
text: Makes sure the block it's spawning on is opaque, that it's not water, and that there are at least 2 blocks of air overhead. } } It does not appear that it checks whether the mob is spawning underground or not.
text: Anecdotally, wandering around for a while with an Xray texture pack produced only surface mobs, so I'm not sure what other guards might be put in place to prevent underground spawns.
answer_details: author: gaming.stackexchange.com/users/5029/John the Green
score: 4
sents: text: Passive mobs will spawn if the following conditions are met:
text: There is a grass block
text: There is 2x2x2 empty space
text: There is a light level above 7
answer_details: author: gaming.stackexchange.com/users/18337/Ryan S.
score: 3
sents: text: No, they can definitely spawn underground.
text: I had a world where I had dug out a massive cavern, encasing all the lava in glass, then placed grass on top of the lava to create big underground islands.
text: I had animals spawning on the grass, at level 13.
text: Edit: This was, however, in an older version of minecraft.
text: I won't be able to check to see if that's still true until I get home.
answer_details: author: gaming.stackexchange.com/users/15092/SaintWacko
score: 1
sents: text: Before they only spawned on chunk generation, I would have them spawn in my grass filled cave all the time, I think they still can, but grass is needed for them to spawn.
answer_details: author: gaming.stackexchange.com/users/16560/legacy
score: 1
sents: text: According to the Minecraft wiki : no, animals cannot spawn underground.
text: newly generated chunks will contain mobs...
text: They will always spawn on the highest available block in a column i.e. the one that can see the sky.
text: For an animal to spawn on it, this block must be opaque and the two blocks above it must be transparent.
text: The block does not need to be grass nor does it need to be illuminated (as it does with [Monster] Spawning).
answer_details: author: gaming.stackexchange.com/users/64041/The Guy with The Hat
score: 1
sents: text: Yes, the passive mobs just need the right conditions.
text: For Pigs, Cows and Chickens you will need light and grass.
text: Getting grass deep underground with out an item hack can be a little difficult.
text: One way would be to dig a hole up to the surface and let natural light strike a block of dirt.
text: From that block you can then grow more grass and from your field of grass you will get passive mobs.
answer_details: author: gaming.stackexchange.com/users/2580/QueueHammer
score: 0
sents: text: I beleive they can.
text: I am playing in 1.7 and I found 3 chickens in my mineshaft.
text: At first I started to look for a way to get to the over world.
text: After an hour or so of searching, I gave up and decided to google to see if they could spawn there.
answer_details: author: gaming.stackexchange.com/users/67174/Nat
score: 0
sents: text: I just found a chicken in my mine, around level 15.
text: I searched and searched, and there are no entrances to the outside.
text: The only possibility that I can think of is that there was a 3x3 patch of dirt in the mine, and a nearby lava source which may have exceeded the light requirement.
text: However, there is obviously no grass around...
answer_details: author: gaming.stackexchange.com/users/76616/Conor
score: 0
sents: text: I found out that the only passive mob that spawns underground is the bat .
text: I found this out while reading my Minecraft Essential Handbook , page 38.
text: Chickens, pigs, cows, and sheep spawn on grass.
answer_details: author: gaming.stackexchange.com/users/127996/Jim Jones
score: 0

Summary of the answers:
They can definitely spawn underground, they just need the right conditions.
While a vague topic, it seems that there need to be special conditions in order to make passive mobs to spawn underground.