mojira.dev
MCPE-102197

Mob spawn range doesn't extend past ~96 blocks horizontally

1.16.100.57 introduces a spawning radius change for simulation range 6 and higher that allows mobs to spawn in a 128 block radius around the player, limited horizontally by the simulation range.
However, chunks will only attempt spawns if the northwest center block of a chunk is within 96 blocks of the player (presumably to prevent the algorithm from being run in far away ticking areas).
This means that despite simulation range 12 leaving enough space horizontally for spawns 128 blocks away, mobs will only spawn in chunks with their center within 96 blocks of the player.

How to reproduce:

  1. Set up two repeat command blocks on a superflat world:
    execute @e ~~~ setblock ~ ~-1 ~ stone
    kill @e (delay 1gt)

  2. Set the simulation range to 12

Expected results:

A hollow circle forms from mobs placing blocks below them, with a radius of 24-128

Actual results:

Chunks of which the center is past 96 blocks from the player do not spawn any mobs.

Linked issues

Attachments

Comments 11

Note: This limitation should ideally be kept for the aforementioned lag reasons, but increased to a little bit past 128 (about 144) to allow the full 128 spawn range to be made use of on simulation range 12.

Also noteworthy: In my test setup, the few stray spots outside of the seen area are endermen teleporting right as they spawn.

I believe this is working as intended. Here is what the 1.16.100.57 changelog says:

  • Mob spawn range now scales with simulation distance (MCPE-95568)

As I read it, all this statement means is that simulation distances higher than 4 will have a wider spawn radius than what simulation 4 has. It doesn't necessarily mean that every incremental increase in simulation distance will have a corresponding incremental increase in spawn radius. Moreover, I'm not sure where you're getting the expectation of r128 spawning.

Aside from issues of interpretation, it's not clear to me what the negative impact on gameplay is here. Mobs only render within 60 blocks of the player, so we're talking about mobs you cannot see. I presume, then, that the concern is just to be able to run farms that can fit more population caps at one time. But r~96 already allows 5 independent cap chunks (chunks with 4 chunks between them), which means more monsters (80) than the Java cap allows (70, afaik).

This is not related to the scaling of the spawn range. The mob spawn range does not increase as you go higher, it decreases as you go down. The radius is 24-128 for all simulation ranges 6 and up (Java Parity). However, this radius is cut down in size horizontally from simulation edge despawn chunks preventing spawns from being made inside of them (this matters on simulation ranges 6-10). The chunks within 96 blocks rule is not part of the mob spawn range scaling, as it is present on all simulation ranges and has been for many versions.
The 128 block radius still works vertically as expected, because chunks are 0-256 vertically. Allowing it to reach the full 128 blocks horizontally on simulation distance 12 is only coherent with the scaling and Java Edition parity.
There is little negative impact on gameplay, but it is nonetheless disparity and comes as an unexpected spawning rule to players.

1 more comments

I built a flat world for testing with 16 x 16 chunks in alternating white and light gray. My simulation distance was at 10. I set it up with some command blocks to teleport me to the exact center point (128.0, 4, 128.0) and then repeatedly test for entities, setblock a red carpet in the block they're in, and kill them. I expected the pattern to be perfectly symmetrical. I was surprised to get this:

[media]

The disturbance that makes it asymmetrical is a set of four chunks along the southeast quarter of the pattern. I outlined them in white for reference. It's a little difficult to see because of the low contrast between the red carpet and light gray concrete, but mobs were spawning in these chunks with the same density as the expected chunks.

A possible explanation might be that these are the only chunks whose center point X and Z coordinates are more than 96 blocks from the player but whose upper left corner coordinates are less than 96 blocks from the player. I didn't actually do the math, but I intuitively feel that's true.

This might also explain why LevelChunk::tick adds 7 instead of 8: The effect is to shift the spawn volume one block toward the northwest, which might have been an attempt to exclude the corner coordinates of the asymmetry-causing chunks. I'm not exactly sure why it didn't work, though I can imagine that shifting it just a little more might succeed. And I have no idea why the code would have been left this way even though it didn't have the desired effect, unless it was tested under conditions where it actually did work, or perhaps it wasn't tested.

The effect of LevelChunk::tick adding 7 instead of 8 to determine chunk centers is exactly the opposite of what Auldrick suggests: it shifts the spawn area to the SE and causes the asymmetry.

Take the top right of the 4 asymmetrical chunks, for example. The +7 "center" of that chunk is 215, 167, so the distances from 128, 128 are 87x and 39z. The Euclidean distance is sqrt ( 87 ^ 2 + 39 ^ 2 ) = 95.34, so spawning occurs in that chunk.

If you go the opposite direction, the +7 "center" of the chunk on the NW side that would mirror the chunk just considered, is at 39, 87. The distances from 128, 128 are 89x and 41z, so the Euclidean distance is sqrt ( 89 ^ 2 + 41 ^ 2 ) = 97.99, so spawning does not occur in that chunk.

If +8 were used to determine chunk centers, the Eudlidean distances to both chunks would be
sqrt ( 88 ^ 2 + 40 ^ 2 ) = 96.66 and spawning would not occur in either chunk.

I ran tests at each Simulation Distance setting to show the pattern of spawnable volume for each. Tests were done in a slightly modified version of the world I used above, where red carpets mark the points where a mob spawned. In these images, there is a central red square of size 20 x 15 x 20 that marks phantoms spawning 21 blocks above the player's position. The space below this is inside the 24-block exclusion sphere; it had no red carpets in any of the experiments.

As you can see, something is causing the pattern of chunks in which spawns can occur to vary unexpectedly for simulation distances 6, 8, 10, and 12 (except that 10 and 12 show the same pattern). Also visible is the fact that the spawnable volume is shifted toward the southeast, which is especially prominent at simulation distance 6.

[media]

[media]

[media]

[media]

[media]

Note: In the SD10 image it appears that the spawn volume for phantoms is larger than in the other pictures, but this is an illusion. It was caused by the fact that I ran that test with the player at Y=20, to verify that the pattern of spawnable chunks doesn't change based on the player's Y coordinate. It didn't affect the spawning volume we're interested in, but it did force the phantom spawn volume higher, and since it was closer to the camera than in the other shots it looks bigger.

The reason for the SE shift your tests of sim 6 and 8 is that the player is standing in the SE chunk of the center 4 chunks. That is, even though 128x. 128z is the geometric center of the test area, it also in the NW corner of the SE-center chunk, and the horizontal spawn area on sim 6 and 8 is chunk based. To put it differently, the center phantom square + not-spawnable areas are shifted to the NW relative to the center of the sim 6 and sim 8 spawnable areas because the player is standing at the NW of the chunk.

On the sim 10 test, the reason the area that was not spawnable in other tests is red is only partially due to phantoms leaving red carpet closer to the camera. It is also partly because having the player is 16 blocks above the ground shrinks the not-spawnable circle on the ground:
sqrt ( 24 ^ 2 - 16 ^ 2 ) = 17.78

Thanks for the explanation. Yes, I realized that the intersection of the 23-block exclusion sphere with the ground would be smaller and the spawnable volume corresponding larger, which contributed to filling the gap between the spawn locations for phantoms vs. other monsters. I just didn't mention it because the thing I wanted to show was the extent of the spawnable chunks. I only mentioned the phantom spawns to explain why the center wasn't empty, as might be expected because of the exclusion zone.

If what you say is true (and I don't doubt that it is), the player's exact position determines the center of the 23-block exclusion sphere at any SimDist and the center of the spawnable sphere at SimDist 4, so I assumed that for SimDist 6 and up the player's exact position would still be the center of a spawnable sphere that would then be extended to include the entire chunk for chunks that the sphere included [some undetermined point, probably the center or NE corner] of. This misapprehension was further reinforced by the confusing exception about mobs spawning more than 96 blocks away, since that likewise suggests a (blockified) sphere. I now get that for SimDist 6 and above, the spawnable chunks are selected based on the center of the chunk the player is in, not the player's exact position. But this makes me wonder how the resulting spawnable region interacts with the player's ticking area, which the last time I checked was symmetrical about the chunk the player is in. This could mean that spawns are possible in chunks that are not actively being ticked. I intend to do some more experiments regarding this possibility.

navynexus

(Unassigned)

418993

Confirmed

Multiple

Windows 10 Pro

1.17.11 Hotfix, 1.16.220, 1.16.100.58 Beta, 1.16.100, 1.16.221 Hotfix, 1.18.2 Hotfix

1.20.50.20 Preview, 1.20.50

Retrieved