Skip to content

Clamp mod-provided progress for bossbars#4203

Merged
aromaa merged 1 commit intoSpongePowered:api-12from
MrHell228:api-12-clamp-bossbar-progress
Apr 3, 2025
Merged

Clamp mod-provided progress for bossbars#4203
aromaa merged 1 commit intoSpongePowered:api-12from
MrHell228:api-12-clamp-bossbar-progress

Conversation

@MrHell228
Copy link
Contributor

Should solve #4200

The progress restriction of [0, 1] is coming from Adventure. Minecraft doesn't have this restriction so mods don't really care about clamping the value they provide. So I think it would be better to just clamp all mod-provided progress

@aromaa
Copy link
Member

aromaa commented Apr 3, 2025

This is going to need more investigation on the rules that vanilla and mods use to render the progress and whatever there is something that Sponge can do here.

The first question is whatever the mod has custom render logic to handle the display of progress?

@MrHell228
Copy link
Contributor Author

MrHell228 commented Apr 3, 2025

This line caused exception mentioned in the issue. It's simply 1 tick when entity is hurt below half health (meaning negative bar progress) and on the next tick bossbar is set to full again (so in this case client basically won't notice anything). Easy fix from mod side.
But I'm not sure why mod would want to do that if game doesn't require progress to be in [0, 1] range.
And unless we want to mixin into Adventure's BossBar and cancel range check, I don't see any other general solution than clamping progress from Sponge side

@aromaa
Copy link
Member

aromaa commented Apr 3, 2025

Thank you, thats all I wanted to know. Its just a bug in the mod and not that they have special rendering.

@MrHell228
Copy link
Contributor Author

MrHell228 commented Apr 3, 2025

Not really a bug if it works as intended in normal circumstances I guess.
It's Sponge that injects whole library that adds constraints on existing object

@aromaa
Copy link
Member

aromaa commented Apr 3, 2025

Minecraft is known to have weird edge cases around values out of the vanilla bounds, so anything unusual is unexpected and could be considered a bug. I'm fairly certain sending out of bounds values for the progress used to produce weird rendering bugs.

Anyways, thaths besides the point. The changes LGTM.

@MrHell228
Copy link
Contributor Author

MrHell228 commented Apr 3, 2025

Yeah, it surely is used. But any solution other than clamping will probably break Adventure's BossBar contract for progress which is not good

Copy link
Member

@aromaa aromaa left a comment

Choose a reason for hiding this comment

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

My point being that we don't usually consider values out of the vanilla bounds to (ever) be valid and try to sanitize them as mods and plugins tend to not do so themselves and lead to all sorts of weird behavior. So this is just another new place to do so, nothing unusual for us.

That being said, thank you again!

@aromaa aromaa merged commit 3bb57ec into SpongePowered:api-12 Apr 3, 2025
5 checks passed
@MrHell228 MrHell228 deleted the api-12-clamp-bossbar-progress branch April 3, 2025 18:07
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.

2 participants