Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.lambda.config.Setting
import com.lambda.config.settings.NumericSetting
import com.lambda.gui.dsl.ImGuiBuilder
import com.lambda.util.extension.CommandBuilder
import com.lambda.util.math.MathUtils.roundToStep
import net.minecraft.command.CommandRegistryAccess
import kotlin.math.roundToInt

Expand All @@ -46,7 +47,9 @@ class DoubleSetting(
private var valueIndex: Int
get() = ((value - range.start) / step).roundToInt()
set(index) {
value = (range.start + index * step).coerceIn(range)
value = (range.start + index * step)
.roundToStep(step)
.coerceIn(range)
}

context(setting: Setting<*, Double>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.lambda.config.Setting
import com.lambda.config.settings.NumericSetting
import com.lambda.gui.dsl.ImGuiBuilder
import com.lambda.util.extension.CommandBuilder
import com.lambda.util.math.MathUtils.roundToStep
import net.minecraft.command.CommandRegistryAccess
import kotlin.math.roundToInt

Expand All @@ -45,7 +46,9 @@ class FloatSetting(
private var valueIndex: Int
get() = ((value - range.start) / step).roundToInt()
set(index) {
value = (range.start + index * step).coerceIn(range)
value = (range.start + index * step)
.roundToStep(step)
.coerceIn(range)
}

context(setting: Setting<*, Float>)
Expand Down
Loading