Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replicate vanilla's loading progess bar better #404

Merged
merged 3 commits into from
Dec 20, 2023

Conversation

Jab125
Copy link
Contributor

@Jab125 Jab125 commented Dec 19, 2023

Better replicate the vanilla progress bar copying over the logic from LoadingOverlay

I've copied the functionality of LoadingOverlay#currentProgress (which is used to render vanilla's progress bar) to the NeoForge overlay.

Minecraft uses this.currentProgress = Mth.clamp(this.currentProgress * 0.95F + f6 * 0.050000012F, 0.0F, 1.0F); where f6 is this.reload.getActualProgress(). Right now, NeoForge only uses this.reload.getActualProgress().

(Visible changes are a smooth progress bar and the very end of the progress bar being slower.)

This PR uses the copied over currentProgress field instead of just this.reload.getActualProgress():

+ this.currentProgress = Mth.clamp(this.currentProgress * 0.95F + this.reload.getActualProgress() * 0.05F, 0.0F, 1.0F);
+ progressMeter.setAbsolute(Mth.ceil(this.currentProgress * 1000));
- progress.setAbsolute(Mth.clamp((int) (this.reload.getActualProgress() * 100f), 0, 100));

It also moves the progressMeter.complete(); call to when the overlay is closed as well as increasing the progress bar's steps to 1000 for 10x smoothness.

One place where the progress bar is different is that vanilla fades the progress bar out when it is done. This can't be done in this PR due to needing to add support in FancyModLoader.

@Jab125 Jab125 marked this pull request as draft December 19, 2023 04:55
@Jab125 Jab125 marked this pull request as ready for review December 19, 2023 04:56
@Minecraftschurli Minecraftschurli added the 1.20 Targeted at Minecraft 1.20 label Dec 19, 2023
@Matyrobbrt Matyrobbrt added the enhancement New (or improvement to existing) feature or request label Dec 19, 2023
@Matyrobbrt Matyrobbrt merged commit b22b15e into neoforged:1.20.x Dec 20, 2023
3 checks passed
embeddedt added a commit to embeddedt/NeoForge that referenced this pull request Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.20 Targeted at Minecraft 1.20 enhancement New (or improvement to existing) feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants