`OptionImpl.BuilderImpl#instant` prevents saving
LucunJi opened this issue ยท 1 comments
- Mod version:
3.5.0+1.21-fabric
How to reproduce
As the title says, it simply prevents saving in all cases.
Analysis
Case 1: the common scenario
- After
OptionImpl#requestSet
:binding().getValue()
andpendingValue
differs; also callsOptionImpl#triggerListeners
- After
OptionImpl#applyValue
:binding().getValue()
andpendingValue
becomes the same - After
YACLScreen#onOptionChanged
:pendingChanges
isfalse
Now the configs won't be the saved since the pendingChanges
is false
. BROKEN.
Case 2: intentionally swap step 2 and 3, it won't be fixed
- After
OptionImpl#requestSet
:binding().getValue()
andpendingValue
differs; also callsOptionImpl#triggerListeners
- After
YACLScreen#onOptionChanged
:pendingChanges
istrue
- After
OptionImpl#applyValue
:binding().getValue()
andpendingValue
becomes the same
It looks fine, but what if we are pressing the Reset button, and the last option hasn't been changed?
- After
OptionImpl#requestSet
:binding().getValue()
andpendingValue
are still the same - After
YACLScreen#onOptionChanged
:pendingChanges
isfalse
- After
OptionImpl#applyValue
:binding().getValue()
andpendingValue
are still the same
Now the configs won't be the saved since the pendingChanges
is false
. BROKEN.
How to fix it
Keep track of the initial value, use a "dirty" flag, etc.
A potential patch is proposed here (I used mixins in my project)