[MC-2102] Mobs spawning inside leaves Created: 03/Nov/12  Updated: 02/Dec/15  Resolved: 02/Dec/15

Status: Resolved
Project: Minecraft: Java Edition
Component/s: None
Affects Version/s: Minecraft 1.4.2, Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w09a, Snapshot 13w09b, Snapshot 13w10a, Snapshot 13w10b, Minecraft 1.5, Snapshot 13w19a, Snapshot 13w21a, Minecraft 1.6.1, Minecraft 1.6.2, Minecraft 13w38a, Minecraft 13w38b, Minecraft 13w38c, Minecraft 1.7.4, Minecraft 14w02c, Minecraft 14w03b, Minecraft 14w04a, Minecraft 14w04b, Minecraft 14w05b, Minecraft 14w06a, Minecraft 14w06b, Minecraft 14w08a, Minecraft 1.7.5, Minecraft 14w10b, Minecraft 14w10c, Minecraft 14w11b, Minecraft 14w26c, Minecraft 14w32a, Minecraft 14w32b, Minecraft 1.8-pre1, Minecraft 1.8, Minecraft 1.8.1, Minecraft 1.8.3, Minecraft 1.8.4, Minecraft 1.8.7, Minecraft 15w35a, Minecraft 15w44b, Minecraft 15w45a
Fix Version/s: Minecraft 15w47c

Type: Bug
Reporter: Ignacio Romang Assignee: [Mojang] Grum (Erik Broes)
Resolution: Fixed Votes: 100
Labels: animal, bush, leaves, mob, spawn, tree
Environment:

Win 7,64bit,Java TM Update 5,Intel Core i7 3.2GHz


Attachments: PNG File 2012-11-03_12.21.39.png     PNG File 2012-11-03_12.21.40.png     PNG File 2012-11-03_12.21.47.png     PNG File 2012-11-03_12.21.49.png     PNG File 2012-11-03_12.21.53.png     PNG File 2013-05-26_10.43.27.png     PNG File 2014-02-08_13.54.22.png     PNG File 2014-02-08_13.54.32.png     Text File jungle-console-results.txt    
Issue Links:
Duplicate
is duplicated by MC-5594 Mobs Can Spawn Stuck in Grass Blocks Resolved
is duplicated by MC-8210 chicken+jungle=bad Resolved
is duplicated by MC-9760 The animals get across the foliages. Resolved
is duplicated by MC-13670 Animals spawning in leaf blocks Resolved
is duplicated by MC-29094 Sheep Spawn in Leafs in Large Forests... Resolved
is duplicated by MC-52524 Mob Spawning Bug Resolved
is duplicated by MC-52841 Cows spawning inside trees Resolved
is duplicated by MC-59576 Pigs spawning in Dark Oak Trees Resolved
is duplicated by MC-299 The error is that when you go through... Resolved
is duplicated by MC-1998 Animals generated in the leaves Resolved
is duplicated by MC-2831 Mobs trapped in leaves, mobs spawning... Resolved
Relates
relates to MC-415 Leaves replace transparent blocks Resolved
CHK:
Confirmation Status: Confirmed

 Description   

The animals are trapped in pastures to spawn...in survival and creative
http://www.youtube.com/watch?v=l3wLq5VnM5E



 Comments   
Comment by Anon Ymus [ 02/Dec/15 ]

Certainly seems fixed; I flew around for a while in the jungle that Markku provided and all the animals seemed to have spawned correctly.

Comment by [Mod] Torabi [ 29/Nov/15 ]

Was this fixed as a result of MC-64492 being fixed?

Comment by Max Roncace [ 24/Aug/15 ]

Still present in 1.9 snapshots (as of 15w35a). The sheep I saw didn't seem to be suffocating, though.

Comment by Marcono1234 [ 17/Jun/15 ]

Confirmed for

  • 1.8.7 I assume the game treats the leaves as non-solid blocks when spawning the animals
Comment by Donovan Piko [ 15/May/15 ]

1.8.4 17 sheep spawned in a leaf block, jungle, and suffocated\
Creative

Comment by MisterSanderson [ 15/Oct/14 ]

In 1.8 I saw an animal on the top of a tree... I think this is related to this bug.

Comment by Orbic [ 20/Sep/14 ]

Still in 1.8

Comment by Niknokinater [ 25/Aug/14 ]

Confirmed in the 1.8 -Pre1.

Comment by a [ 07/Aug/14 ]

Animals are spawning inside leaves in 14w32b.

Comment by insomniac_lemon [ 30/Apr/14 ]

So, because of MC-46765 animals spawned in leaves suffocate. Why is that, can chickens somehow exploit this to grief? Can sheep use it to find ores? Can pigs use it to gain an advantage in SMP?

Come on, something to manage player balance should only affect players. Mobs don't spawn normally as it is, so having a big chunk of them die in leaves because of an X-ray issue is a big problem and frankly stupid.

Comment by Markku [ 08/Mar/14 ]

Affects 14w10c. Used creative mode and seed -4542366974610774625, fly, /tp ... 1200 120 800, let the area generate, fly lower and around. At least 3 groups of sheeps with at least one sheep inside leaves initially. They do seem to get out eventually, jumping on top of the leaves they spawn in, so if taking too long looking for them, they will be free already.

Comment by Anon Ymus [ 08/Feb/14 ]

Suffocation in leaves: MC-46765
The animals that are only 1 block tall or shorter have their head in the leaves, and so, suffocate. The animals that are 1.5 blocks tall or more don't have their heads in a leaf block, so they don't suffocate.

Comment by [Mod] Ezekiel (ezfe) [ 08/Feb/14 ]

That is probably because they suffocate due to another bug.

Comment by Itouch2 [ 08/Feb/14 ]

I've the feeling that mobs appear less often in the leaves in 06b but this is still the case. Some mobs suffocate while others do not.

Comment by [Mod] Torabi [ 25/Jan/14 ]

While you can't include screenshots in a comment (other than providing a link to one), you can attach one to an issue by clicking the "Attach Files" button at the top of the page.

Actually, you can include images in comments. If it's already attached to the ticket, you can just surround its filename with exclamation points. If it's uploaded elsewhere, you can use the full URL of the file.

Comment by Foster L. Smith [ 24/Jan/14 ]

They are! I was playing in a 14w04a survival world, and I found a sheep inside a leaf block! And I also have a question: How do I upload screenshots on comments?

Comment by [Mod] Ezekiel (ezfe) [ 22/Jan/14 ]

Is this still a concern in the latest Minecraft version 14w03b? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Comment by PTR_91 [ 02/Dec/13 ]

Confirmed for 13w48b. I saw a few chickens inside one of those miniature one-log-block jungle trees.

Comment by Grzegorz JagodziƄski [ 23/Sep/13 ]

Confirmed: affects 13w38c. It even seems that the number of mobs trapped in leaves has grown (more mobs spawn in leaves than before).

Comment by Vrej [ 21/Sep/13 ]

Confirmed.

Comment by Markku [ 11/Jul/13 ]

Affects 1.6.2 (situation same as couple comments ago, my test seed now produces only chickens near the spawn, but some of them are inside leaves).

Comment by Allaiyah Weyn [ 27/Jun/13 ]

I've seen sheep spawning inside of trees & jungle bushes ever since we got the jungle biomes. Used to be pigs too.

Comment by Markku [ 04/Mar/13 ]

Affects 13w10a. Found cows in another world's jungle, one of them stuck in leaves.

Comment by Markku [ 28/Feb/13 ]

Affects 13w09b. Interesting though, I could only find chickens in the test-jungle. Nevertheless, both me and many of the chickens were spawned inside leaves.

Comment by Markku [ 17/Feb/13 ]

Fix
Original code:

SpawnerAnimals.performWorldGenSpawning()
    ...
    if (canCreatureTypeSpawnAtLocation(EnumCreatureType.creature, par0World, var10, var17, var11)) {
        float var18 = (float)var10 + 0.5F;
        float var19 = (float)var17;
        float var20 = (float)var11 + 0.5F;
        EntityLiving var21;

        try {
            var21 = (EntityLiving)var8.entityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par0World});
        } catch (Exception var23) {
            var23.printStackTrace();
            continue;
        }

        var21.setLocationAndAngles((double)var18, (double)var19, (double)var20, par6Random.nextFloat() * 360.0F, 0.0F);
        par0World.spawnEntityInWorld(var21);
        creatureSpecificInit(var21, par0World, var18, var19, var20);
        var15 = true;
    }
    ...

Fixed, with MCP naming and my own additional variable name interpretations:

SpawnerAnimals.performWorldGenSpawning()
    ...
    if (canCreatureTypeSpawnAtLocation(EnumCreatureType.creature, world, spawnX, spawnVerY, spawnHorZ)) {
        float var18 = (float) spawnX + 0.5F;
        float var19 = (float) spawnVerY;
        float var20 = (float) spawnHorZ + 0.5F;
        EntityLiving var21;

        try {
            var21 = (EntityLiving) var8.entityClass.getConstructor(new Class[] { World.class }).newInstance(new Object[] { world });
        } catch (Exception var23) {
            var23.printStackTrace();
            continue;
        }

        // FIX:
        boolean doSpawn = true;
        int blockId = world.getBlockId(spawnX, spawnVerY, spawnHorZ);
        if (blockId != 0 && Block.blocksList[blockId].blockMaterial == Material.leaves) {
            doSpawn = false;
            for (int climbLeaves = 1; climbLeaves <= 3; climbLeaves++) {
                blockId = world.getBlockId(spawnX, spawnVerY+climbLeaves, spawnHorZ);
                if (blockId == 0) {
                    var19 += climbLeaves;
                    doSpawn = true;
                    break;
                }
            }
        }
        // Continue as before if the block is considered suitable:
        if (doSpawn) {
            var21.setLocationAndAngles((double) var18, (double) var19, (double) var20, chunkProvidersRandom.nextFloat() * 360.0F, 0.0F);
            world.spawnEntityInWorld(var21);
            creatureSpecificInit(var21, world, var18, var19, var20);
            spawned = true;
        }
    }
    ...

The fixed code above may have some oopsies as I had to slightly clean it up without checking (the real version has plenty of debugging nonsense in it), but the idea is clear.

Also, a better fix would be to provide another method in world class that already seeks for the place above leaves, so that the method can be used by other spawning routines, too. For example, (by MCP naming) WorldGenShrub would also benefit from the same/similar fix, and there is another similar spawner method in the same SpawnerAnimals class.

I've attached a console log file 'jungle-console-results.txt' showing a little bit of what is happening when the fix is applied (and also with a check, but no fix, in the WorldGenShrub class).

A good seed to check the results could be 4541576050680254111; it has several animals blocked in the leaves quite near the spawn. (Also, as an additional benefit, that is a good seed to test the problem of player spawned inside leaves, as it seems to do so very frequently, including a case where I spawned standing on a branch of a "big tree", inside leaves.)

Comment by Markku [ 17/Feb/13 ]

There are two ways the game gets animals inside leaves.

One is when an animal has already been created and the terrain generator creates a bush (in jungle) without checking where it puts its leaves. This is somewhat rare (like 2-3 cases when generating new world and starting near a jungle).

The other is when an animal is being spawned and the leaves are already there. The spawning routine asks the world object for the top solid or liquid block (i.e. ground or water surface). However, this indeed returns the ground level; The method has specific check to ignore leaves. It then checks the creature type if it is ok to spawn in the block, but this check only considers things like water animal into water. This mistake of ignoring leaves and using blindly the ground level causes most of trouble; like 33 cases with the same jungle as those 2-3 other cases. (Edit: note, some of those 33 may get themselves out of the leaves by themselves.)

Comment by Anon Ymus [ 09/Jan/13 ]

I have seen this happen with cows, pigs, and chickens too. You were probably just unlucky.

Comment by Travis Ralston [ 09/Jan/13 ]

Confirmed as well, and just cause: http://home.turt2live.com/sheep.png

It seems to only happen to sheep, and only in specific spots. I've noticed that after I free the sheep very often there is another sheep there a couple hours later

Comment by David Knag [ 31/Dec/12 ]

Confirmed. This happens to me all the time.

Comment by C.J. Wijtmans [ 08/Dec/12 ]

its not a bug its a feature.

Comment by Frapjump [ 08/Dec/12 ]

Seen this issue many, mnay times.

Comment by Anon Ymus [ 22/Nov/12 ]

But the animal AI doesn't try to get out of leaves, and so the animal is stuck there until the block it is in is destroyed.

Comment by FireHunterX [ 22/Nov/12 ]

You can't die in leaves. And unless you stand right next to a sapling and bone meal it, it won't happen again.
It's a one-time thing.

Comment by Tom Mate [ 21/Nov/12 ]

happens very often when I play! NOT ONLY in jungles. every tree leafs! Shouldn't be that difficult to fix I guess

Comment by Vit Musienko [ 09/Nov/12 ]

Yes, its especially annoing in jungle biomes

Comment by Maarten Thijs [ 05/Nov/12 ]

arthur stop starting every word of your sentence with a capital!!!!

Comment by fuj1n (Arthur Uzulin) [ 05/Nov/12 ]

@Tyron That And It Also Spawn The Jungle Over The Mobs A Lot Of Times During World Generation

Comment by Tyron [ 05/Nov/12 ]

The fix is quite simple I think. The spawning Algo currently checks if the the block to spawn on is translucent, but instead it should check if the block has a bounding box where entities collide on.

Comment by Chalmes (Jon) [ 04/Nov/12 ]

Duplicate of MC-1998

Comment by Luke Anderson (stuntguy3000) [ 03/Nov/12 ]

This has been around since before 1.4, Basically animals spawn on the grass, in the leaf blocks.

Comment by Mustek [ 03/Nov/12 ]

Please provide a description of your issue, and not just pictures.

Generated at Sun Jan 12 11:56:43 UTC 2025 using Jira 9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13.