Skip to content

Fix ticking distances (mob spawn range, entity, chunk and block ticking distances)#7053

Closed
rafaelsms wants to merge 4 commits into
PaperMC:masterfrom
rafaelsms:fix-sim-dist-2
Closed

Fix ticking distances (mob spawn range, entity, chunk and block ticking distances)#7053
rafaelsms wants to merge 4 commits into
PaperMC:masterfrom
rafaelsms:fix-sim-dist-2

Conversation

@rafaelsms
Copy link
Copy Markdown

  • Mob spawn range: trackers have been updated to use Spigot's mob spawn range instead of MOB_SPAWN_RANGE (static value of 8)
  • Mob spawn range is still limited to 8 chunks max, but now we either limit it by the view distance or the simulation distance, the greatest of both
  • Trackers that used view distance have been replaced with simulation distance (such as ticking blocks and entities) as we would only iterate through more chunks without any benefit
  • Chunk ticking now uses the maximum range between mob spawn and chunk ticking (which uses simulation distance), it'll check only one condition and assume the other one
    • for example, if mob spawn > simulation distance, we will iterate every chunk in mob spawn range, but we will only check if we should tick on those chunks
    • if mob spawn < simulation distance, we will iterate every chunk in simulation distance, but we will only check if we should spawn mobs on those chunks
  • Entity activation is already updated by Spigot's ActivationRange, which is limited by simulation distance
  • Entity ticking already checks chunk's ticking tracker

@rafaelsms rafaelsms requested a review from a team as a code owner December 6, 2021 20:06
}
} else {
- final double range = (DistanceManager.MOB_SPAWN_RANGE * 16) * (DistanceManager.MOB_SPAWN_RANGE * 16);
+ final double range = (level.spigotConfig.simulationDistance * 16.0) * (level.spigotConfig.simulationDistance * 16.0);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is executed when reducedRange = false, which is removed from the code now (after this patch, reducedRange = true always)

@rafaelsms
Copy link
Copy Markdown
Author

rafaelsms commented Dec 8, 2021

#7054 will be fixed by this PR (edit: I don't know how to link issues)

@MiniDigger MiniDigger linked an issue Dec 8, 2021 that may be closed by this pull request
@electronicboy
Copy link
Copy Markdown
Member

modifications to existing patches should be made in those patches rather than creating an additional one

@rafaelsms
Copy link
Copy Markdown
Author

modifications to existing patches should be made in those patches rather than creating an additional one

Ok! I'll try to do it later. The last time I tried, I couldn't get it to rebuild patches correctly from the commits and some changes were left out in some patches. I'll try to do it again more cleanly this time. Any tip would be appreciated.

@rafaelsms
Copy link
Copy Markdown
Author

Well, the block ticking issue was fixed by Spottedleaf (758e2a7), so I will close this as my changes are a little bit hash on vanilla working.

@rafaelsms rafaelsms closed this Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[1.18] Simulation distance behaves differently than vanilla

2 participants