Mojira Archive
MC-154090

Pillagers in outposts inconsistently spawn at light level 8, unlike other mobs

The bug

Both mobs and pillagers from outposts spawning is affected by block light level, but pillagers from outposts spawn at block light levels 8 or less instead of 7 or less (prior to 1.18) or 0 like other mobs.

How to reproduce

Use the seed 7703073064123265302 and run the following commands:

  1. Teleports to pillager outpost.
    /tp @p 1175 65 855
    
  2. Sets the world border to restrict spawning area.
    /worldborder set 63
    
  3. Centers the world border.
    /worldborder center 1175.5 855.5
    
  4. Removes terrain.
    /fill 1144 85 824 1206 64 846 air
    
  5. Removes more terrain.
    /fill 1206 72 847 1144 64 886 air
    
  6. Places platform for pillagers and mobs to spawn on.
    /fill 1206 64 824 1144 64 886 polished_blackstone
    
  7. Sets block light level to 7.
    /fill 1206 73 824 1144 73 886 minecraft:shroomlight
    
  8. Clears pillagers and mobs. 
    /kill @e[type=!minecraft:player]
    

     Notice that both pillagers and other mobs are spawning, as the light level is 7.

  9. Sets block light level to 8.
    /fill 1206 72 824 1144 72 886 minecraft:shroomlight
    
  10. Clears pillagers and mobs.
    /kill @e[type=!minecraft:player]
    

     Notice that even though the light level is 8, pillagers are still spawning.

  11. Sets block light level to 9.
    /fill 1206 71 824 1144 71 886 minecraft:shroomlight
    
  12. Clears pillagers.
    /kill @e[type=!minecraft:player]
    

     Notice that nothing spawns, as the light level is 9.

Code analysis

1.16.2-rc1, Mojang names

net.minecraft.world.entity.monster.PatrollingMonster.checkPatrollingMonsterSpawnRules(EntityType<? extends PatrollingMonster>, LevelAccessor, MobSpawnType, BlockPos, Random) allows light level <= 8.
net.minecraft.world.entity.monster.Monster.isDarkEnoughToSpawn(ServerLevelAccessor, BlockPos, Random) allows light level <= Random.nextInt(8) which is 0-7 (both inclusive).