Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-227735

Zombie reinforcements can spawn on biomes where regular zombies can't

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 1.17 Release Candidate 2, 1.17, 1.17.1 Pre-release 1, 1.17.1 Pre-release 2, 1.17.1 Pre-release 3, 1.17.1 Release Candidate 1, 1.17.1 Release Candidate 2, 1.17.1, 21w37a, 21w38a, 21w40a, 21w42a, 21w44a, 1.18 Pre-release 1, 1.18 Pre-release 4, 1.18 Pre-release 6, 1.18 Release Candidate 1, 1.18.1 Release Candidate 1, 1.18.1 Release Candidate 2, 1.18.1, 22w05a, 1.18.2 Pre-release 1, 1.18.2 Pre-release 3, 1.18.2, 22w14a, 22w18a, 22w19a, 1.19, 1.19.1 Release Candidate 2, 1.19.2, 23w07a, 1.20 Pre-release 4
    • Confirmed
    • Mob spawning

      The bug

      Zombie reinforcements can spawn on the following biomes: Mushroom Fields, Mushroom Field Shore, The Void, and all Nether and End biomes, even though zombies naturally don't spawn in those biomes.

      Steps to reproduce

      1. Create a single biome world of one of the previously mentioned biomes, on creative mode (or go to The End).
      2. Set the difficulty to Hard.
      3. Set command blocks to constantly kill any mob that is not either a zombie or the player (you cannot execute the command /gamerule doMobSpawning false, as that disables reinforcements). This is not necessary, but it assures that other mobs won't interfere or attempt to kill the player.
      4. Set the time to night.
      5. Spawn a zombie that can summon reinforcements inside it:
        /summon zombie ~ ~ ~ {Attributes:[{Name:"zombie.spawn_reinforcements",Base:1.0},{Name:"generic.movement_speed",Base:0.0}]}
      6. Switch the gamemode to survival, and hit the zombie a few times.
      7. Zombie reinforcements will spawn.

      Expected results

      Zombie reinforcements should not spawn in biomes where zombies can't spawn (especially in the void).

      Code analysis

      Using 1.18.2-pre1, Mojang mappings
      The logic for zombie reinforcement is in the method net.minecraft.entity.monster.Zombie.hurt(DamageSource, float); it contains several checks, including NaturalSpawner.isSpawnPositionOk(...) which checks for an empty valid spawn block within the world border, and SpawnPlacements.checkSpawnRules(...) which checks monster spawn rules (brightness, not in Peaceful mode). However, none of these methods seem to check for biomes where zombies can naturally spawn.

      Potential fix:
      Using 1.19.2, Mojang mappings
      Change this piece of code of Zombie#hurt from:

      ...
                      BlockPos $$12 = new BlockPos($$9, $$10, $$11);
                      EntityType<?> $$13 = $$7.getType();
                      SpawnPlacements.Type $$14 = SpawnPlacements.getPlacementType($$13);
                      if (!NaturalSpawner.isSpawnPositionOk($$14, this.level, $$12, $$13) || !SpawnPlacements.checkSpawnRules($$13, $$2, MobSpawnType.REINFORCEMENT, $$12, this.level.random)) continue;
      ...
      

      To:

      ...
                      BlockPos $$12 = new BlockPos($$9, $$10, $$11);
                      EntityType<?> $$13 = $$7.getType();
                      SpawnPlacements.Type $$14 = SpawnPlacements.getPlacementType($$13);
                      Holder<Biome> biome = $$2.getBiome($$12);
                      if (biome.is(BiomeTags.IS_NETHER) || biome.is(BiomeTags.IS_END) || biome.is(BiomeTags.WITHOUT_ZOMBIE_SIEGES) || biome.is(BiomeTags.WITHOUT_WANDERING_TRADER_SPAWNS)) continue;
                      if (!NaturalSpawner.isSpawnPositionOk($$14, this.level, $$12, $$13) || !SpawnPlacements.checkSpawnRules($$13, $$2, MobSpawnType.REINFORCEMENT, $$12, this.level.random)) continue;
      ...
      

      There is probably a much better way to fix this, but this works.

            Unassigned Unassigned
            ampolive [Mod] ampolive
            Votes:
            16 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: