mojira.dev
MC-115757

Chickens hatch from eggs under the gamerule doMobSpawning false

I entered the command

/gamerule doMobSpawning false

and tried to spawn baby chickens by throwing a chicken egg, and they spawned.

I also disabled mobGriefing, if the bug is associated with it.

Attachments

Comments 44

This doesn't seem like a bug, of course they still spawn from the egg. That'd be like turning doMobSpawning off and expecting that pigs will stop spawning from the spawn egg you're placing on the ground. I bet a dime that this is intentional, and not at all a glitch.

In a way, the regular egg can be seen as some sort of Survival-spawn egg, so I'd also assume on first glance that it is intended.. Which reminds me a bit of MC-61006 and MC-69151, where NoAI-Chicken or AI-chicken with Mobloot-gamerule off still lay eggs, which I personally would prefer to be adjustable for mapmaker's sake at least (maybe with another tag) and not WaI/Won't Fix for both, but that's another thing.

I guess we need to live with some exceptions from the rules or special cases every now and then 🙂

Confirmed for 1.12 pre-1.

Confirmed for 1.12 pre-3.

I would agree this is probably WAI - doMobSpawning affects natural spawning - not manual spawning such as /summon and spawn eggs.

To me, throwing an egg is manual spawning, since you have to use the egg to spawn the chicken.

34 more comments

I can also confirm this in 1.18.1. This behavior is inconsistent with how endermites are summoned from ender pearls. If the "doMobSpawning" gamerule is set to "false", endermites won't be able to spawn when a thrown ender pearl breaks.

Here's a code analysis along with a potential fix regarding this issue. The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

Code Analysis:

net.minecraft.world.entity.projectile.ThrownEgg.java

public class ThrownEgg extends ThrowableItemProjectile {
   ...
   protected void onHit(HitResult $hr) {
      super.onHit($hr);
      if (!this.level.isClientSide) {
         if (this.random.nextInt(8) == 0) {
            int i = 1;
            if (this.random.nextInt(32) == 0) {
               i = 4;
            }

            for(int j = 0; j < i; ++j) {
               Chicken chicken = EntityType.CHICKEN.create(this.level);
               chicken.setAge(-24000);
               chicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
               this.level.addFreshEntity(chicken);
            }
         }

         this.level.broadcastEntityEvent(this, (byte)3);
         this.discard();
      }

   }
   ...

If we look at the above class, we can see that no checks are carried out to check what the value of the "doMobSpawning" gamerule is, when a chicken is summoned from a thrown egg.

Potential Fix:

Adding an "if" statement somewhere within this class to check the value of the "doMobSpawning" gamerule before a chicken is summoned from a thrown egg, would resolve this problem. In other words, the "if" statement would have to contain the following line of code somewhere:

this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)

Can confirm in 1.18.2. Just to reiterate, this behavior is inconsistent with how endermites are spawned from ender pearls so this is probably worth mentioning.

Can confirm in 1.19.

Can confirm in 1.19.2.

I think the example of the ender pearl is invalid here, because generating endmites is not the main function of the ender pearl. The main function of eggs is to produce chickens.

JUE13

(Unassigned)

Confirmed

Mob spawning

chicken, doMobSpawning, egg, gamerule

Minecraft 1.11.2, Minecraft 17w14a, Minecraft 17w15a, Minecraft 17w16a, Minecraft 17w17a, ..., 1.19.4, 1.20 Pre-release 5, 1.20.1, 1.20.5, 1.20.6 Release Candidate 1

Retrieved