Fix Sodium option sliders not respecting vanilla clamping #1905
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Currently the Sodium option sliders for view & simulation distance use hardcoded minimum/maximum values instead of pulling these values from the vanilla option objects. This introduces a parity break from vanilla, as it normally clamps the maximum view distance to 16 if less than 1GB of RAM is allocated to the game. It also means that any mods modifying the default bounds vanilla places on these options (e.g. to lower minimum simulation distance) would need to patch Sodium for the change to apply.
This PR fixes that by attempting to retrieve the vanilla value for the minimum and maximum, and falling back to the Sodium-provided constant if not possible. I used wrapper functions to try and keep the code in the actual Sodium options as simple as possible.
If there is a technical reason why Sodium should not respect the vanilla bounding, this PR doesn't need to be merged, but it was a simple enough change that I felt I should just go ahead and submit anyway.
Attached is a screenshot showing the fix for the parity break described earlier (heap size set to 512MB, and maximum render distance is now clamped to 16).