owo-lib Config Screen: Integer Slider with @RangeConstraint(min=1) Visually Defaults to 0 on Initial
DawsonBodenhamer opened this issue · 0 comments
I'm seeing a visual issue with an integer slider in my mod's config (MC 1.21.1, owo-lib 0.12.15.4+1.21).
Problem:
An int option, maxGroupSize, is defined in my ModConfigModel.java with @RangeConstraint(min = 1, max = 10) and a default of 1. The generated ModConfig.java and the adorablehamsterpets.json5 file correctly reflect this default or user-set values. Game logic uses the correct value fine.
The UI issue:
- Initial Display: On first opening the config screen, the
maxGroupSizeslider shows 0. - Click Behavior: Clicking the slider (without dragging) makes it jump to 1.
- Reset Button: Works correctly, sets to 1.
- Re-opening Screen: If changed, then "Done" is clicked, re-opening the config screen shows the slider back at 0 visually, though the
.json5file and game logic use the correct saved value.
It seems the UI slider might not apply the min constraint for its initial visual render or doesn't immediately display the loaded/default value correctly.
Video of the issue:
@Blodhgarm on Discord said:
"Can you try setting the decimal places to 0 in the attribute? The attribute has control over how much precision there is and I wonder if its just a visual glitch with rounding and I wound if setting the value from 2 to 0 it will show the correct value."
So I followed his instruction like this,
@Comment("Maximum hamsters per spawn group. Because sometimes one just isn't cute enough.")
@RangeConstraint(min = 1, max = 10, decimalPlaces = 0)
public int maxGroupSize = 1;
But it did not fix the issue.
Any ideas what might cause this visual-only discrepancy or if there's a known workaround?
Thanks!