Show the resulting value on number step buttons

Each step button on the number screen shows the value it leads to, and
marks when that value is the minimum or maximum.
This commit is contained in:
2026-10-26 10:20:50 +01:00
parent 32797bd2a8
commit 38a33b7298
3 changed files with 12 additions and 4 deletions
@@ -86,10 +86,12 @@ class ValueEditors {
private SWItem stepItem(Player player, Material material, double delta, double step, double value, double min, double max, boolean integer, Predicate<Double> apply, Runnable reopen) {
String label = (delta < 0 ? "§c-" : "§a+") + number(Math.abs(delta));
return new SWItem(material, label, clickType -> {
// Snap to the step grid and drop floating point noise, so repeated steps do not drift
double next = integer ? Math.round(value + delta) : Math.round(Math.round((value + delta) / step) * step * 1e6) / 1e6;
apply.test(Math.max(min, Math.min(max, next)));
// Snap to the step grid and drop floating point noise, so repeated steps do not drift
double unclamped = integer ? Math.round(value + delta) : Math.round(Math.round((value + delta) / step) * step * 1e6) / 1e6;
double next = Math.max(min, Math.min(max, unclamped));
String limit = next == max && unclamped >= max ? "PARTICLE_NUMBER_AT_MAX" : next == min && unclamped <= min ? "PARTICLE_NUMBER_AT_MIN" : "PARTICLE_NUMBER_RESULT";
return new SWItem(material, label, List.of(msg(limit, player, number(next))), false, clickType -> {
apply.test(next);
reopen.run();
});
}