File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
src/main/kotlin/com/lambda/config/settings/numeric Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import com.lambda.config.Setting
2626import com.lambda.config.settings.NumericSetting
2727import com.lambda.gui.dsl.ImGuiBuilder
2828import com.lambda.util.extension.CommandBuilder
29+ import com.lambda.util.math.MathUtils.roundToStep
2930import net.minecraft.command.CommandRegistryAccess
3031import kotlin.math.roundToInt
3132
@@ -46,7 +47,9 @@ class DoubleSetting(
4647 private var valueIndex: Int
4748 get() = ((value - range.start) / step).roundToInt()
4849 set(index) {
49- value = (range.start + index * step).coerceIn(range)
50+ value = (range.start + index * step)
51+ .roundToStep(step)
52+ .coerceIn(range)
5053 }
5154
5255 context(setting: Setting <* , Double >)
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import com.lambda.config.Setting
2525import com.lambda.config.settings.NumericSetting
2626import com.lambda.gui.dsl.ImGuiBuilder
2727import com.lambda.util.extension.CommandBuilder
28+ import com.lambda.util.math.MathUtils.roundToStep
2829import net.minecraft.command.CommandRegistryAccess
2930import kotlin.math.roundToInt
3031
@@ -45,7 +46,9 @@ class FloatSetting(
4546 private var valueIndex: Int
4647 get() = ((value - range.start) / step).roundToInt()
4748 set(index) {
48- value = (range.start + index * step).coerceIn(range)
49+ value = (range.start + index * step)
50+ .roundToStep(step)
51+ .coerceIn(range)
4952 }
5053
5154 context(setting: Setting <* , Float >)
You can’t perform that action at this time.
0 commit comments