mojira.dev
MCPE-58670

Some surface spawns have become cave spawns

Since 1.14.0 was released, some mob spawns that should be surface spawns are now producing cave mobs instead. Specifically, if the block with sky access is a bottom slab or non-solid block, a mob spawning in the first open space below it should be tagged as a surface mob (i.e. subject to the surface mob density cap), but as of 1.14.0 they are not being tagged and are instead subject to the cave mob density cap.

This issue can cause mob farms to spawn more slowly than they ought to. In fact, a simple mob farm that was built such that it only generated surface monsters would no longer spawn anything.

I have attached a world that demonstrates this problem.

World Description:

The world has 3 locations you will use: A Spawn Room, a Testing Room, and the Surface. Command blocks are provided to teleport you between these locations.

The world is designed so that only monsters can spawn in it, and only on the spawn floor. (Technically, bats, slimes, and wandering traders can also spawn, but they're immediately killed by repeating command blocks.)

You spawn on the surface in front of a blue square centered in a yellow ring and, farther out, a purple ring. The spawn floor is at Y=68 below the blue square; it is one chunk in size. The purple ring encloses the density cap measurement area for spawns on the spawn floor; it is 9 x 9 chunks in size. The yellow ring encloses the area you need to stay within to prevent mobs from spawning outside the density cap area.

Except for the Spawn Room and the Testing Room, which are mobproofed, the density cap area is entirely filled with stone. This ensures that only monsters can spawn during the test and they can only spawn on the spawn floor. It also ensures that there are no unknown monsters taking up part of the density cap.

The Testing Room is at Y=43, just outside the spawn floor chunk. It's like an AFK room in that when the player is within it, all blocks of the spawn floor are within spawning range The Testing Room also has a lever that controls the "mobspawning" game rule, and a repeating command block that every 10 seconds reports what mobs are present on the spawn floor.

Steps to reproduce:
1. Open the attached world Monster Spawn Lab 2.mcworld.
2. Press the button to teleport to the Spawn Room. Verify that there are no mobs on the spawn floor or in the mob holding pen. If there are, use the Kill Mobs On Spawn Floor button to get rid of them.)
3. Go to the Testing Room and flip the lever to enable mob spawning. A repeating command block will start outputing a list every 10 seconds of any mobs found on the spawn floor or in the holding pen. Wait until 8 mobs are listed; it should take less than 5 minutes. (The density cap for hostile mobs is 8, so no more will spawn if you wait longer.)
4. Disable mob spawning.
5. Go to the Spawn Room. You should see 8 mobs on the spawn floor. Use the button to teleport them to the holding pen. (Note that the pen is outside the spawn floor chunk, but still inside its density cap area.)
6. Go to the surface.
7. Place a bottom slab or any non-solid block in front of the bottommost observer. Command blocks will replicate your block over the entire chunk, so that every block of the spawn floor has your block on the surface above it. This configuration should spawn surface cap monsters.
8. Return to the Testing Room and enable mob spawning again. Wait a few minutes to see if any monsters spawn.

Expected results:
The monsters currently in the holding pen are all cave mobs, but no surface mobs have been spawned so far, so up to 8 new monsters will spawn on the spawn floor.

Actual results:
No more monsters spawn. If at this point you kill the monsters in the holding pen (there's a button for that purpose), the cave density cap will be opened again and up to 8 new monsters will spawn. The fact that they are cave spawns can be verified by checking the Surface property of the entity for each mob.

Linked issues

Attachments

Comments 6

Developers: A code analyzer on the TechRock Discord discovered what they think is the cause of this problem, using reverse engineering. They were actually researching MCPE-54241 and posted their explanation in a comment there. It was then realized that the same bug would likely cause this problem, so I verified that it did and created this ticket to report it. If the analysis is correct, the fix should be checked to ensure that it fixes both bugs.

Related to this, mobs can actually spawn on a bottom half slab and transparent blocks such as glass, leaves, chests, etc.

Thank you for mentioning that. I had meant to link that issue but entered the wrong ticket number in the "relates to" link. Corrected now.

I have been testing different spawn surfaces in a single-player superflat world with spawn platforms at y=40 & 43 and lava covering the ground below across the entire simulation distance. I have found:

  1. If the block with sky access is carpet, it will still trigger surface spawns below. (Try placing carpet in your test world instead of bottom slabs!)

  2. I do not get any mobs spawning on bottom slabs or carpet, but I do get mobs spawning on glass, leaves, stairs, etc.

That said, I am confused by this bug report. Is this "bug" not just the (intended?) resolution to MCPE-41273? Is there some middle ground that you think ought be achieved between the two?

For what it's worth, this "bug" also seems to resolve MCPE-45183 and MCPE-58285 (the latter at least as it pertains to enclosed villager-base farms like the one shown in the picture attached to that report).

MCPE-41273 was about surface spawns happening anywhere under leaves, slabs, and stairs, no matter how deep the space was where the spawn happens. I think everybody would agree that it doesn't make sense to call a mob spawning at Y=6 a "surface" mob (unless the whole chunk has been dug out and the surface really is that far down). This ticket is about the opposite site of the coin: flagging spawns as cave spawns when they're actually occurring on the surface (in the sense of "surface" that the game uses).

You have to take a larger view of the issues, not just look at rules based on block types.

  • Q: Why distinguish between surface and cave spawns in the first place?

  • A: Because the surface and the underground have very different distributions of spaces where spawns can occur, so they need different mob caps to achieve balanced spawning. Also, once you make the distinction a thing, it becomes useful for future spawn tweaking. For instance, recently some kinds of despawning have been added. It might be good to have the flexibility of different despawn rules for surface and cave mobs, so the distinction can become even more important over time.

  • Q: Why are exceptions made for leaves, slabs, and stairs? Why isn't the "surface" just the top block below the sky?

  • A: Because "surface" is an intuitive concept players derive from information not available to the game. Humans judge what a surface is using information like the prevailing local ground level and whether the block you're considering would be one you'd be likely to walk on. For the game to try and calculate local ground level would be computationally expensive, and it doesn't have any way of knowing whether our furnace is meant for smelting or we just liked its top texture for our floor. If the game just looked at sky access, anywhere indoors or under a tree would be in a cave, which is silly. So it makes an exception for leaves, because 99% of them are in trees, and an exception for stairs and slabs, because those are what experienced player put on their roofs.

  • Q: OK, then why was there any problem with this?

  • A: I think it was originally true that to qualify as an exception, a stair or slab could have at most one solid block below it, with air below that. That's a pretty good definition of a generic roof, and also accommodates additional lower floors of a building as surfaces for spawning if the intervening floors are also made of slabs. At some point, however, that single-solid-block condition was lost from the code, possibly to fix some problem the exceptions weren't handling well enough. The unfortunate result was that from then on, "surface" spawns could occur at any depth, all the way to bedrock. Nobody noticed it for a while, because the randomness of spawning added enough noise that the change in pattern wasn't easily detectable. I only found it by looking at data in the world save. So my intent with MCPE-41273 was to get these "deep surface" spawns eliminated, but not to change how spawning works near the actual surface. I tried to suggest a depth limit in that ticket, though I don't know enough to predict what effect that would have, so I really left it up to the game designers to decide how the exception logic might need to be changed.

This ticket is about those near-surface spawns, the ones that are "surface" only because of the exceptions. As explained above, it's important that leaves, slabs, and stairs are not considered surfaces for spawning, so that the spawn locations will get pushed downward to the actual ground under a tree or floor in a building. That does not conflict with leaving deep spawns as cave spawns. I'm looking for that middle ground you speculated about.

I do expect the fix for this bug to have consequences for other tickets, possibly even to resolve them. Quite a lot of the spawning logic seems to be generic, used for all mobs and situations, so interactions are to be expected. However, without detailed documentation about how spawning works and with no access to the code, we can't predict how a particular patch will manifest in those interactions. It's an extremely complex system, and we have to leave it up to the developers whether to try to fix just the specific bug or to ask the designers to come up with a more generic solution that solves multiple problems.

This issue was fixed in 1.14.1 with the fix for MCPE-54241.

Auldrick

(Unassigned)

288241

Confirmed

Windows

cave-spawn, spawn, surface-spawn, transparent-block

1.14.0

Retrieved