From 928bc5df6c6214a09113908afb2c2a8c76d68b52 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 13 Nov 2024 18:26:32 -0600 Subject: [PATCH] Fix setting saturation to 0 crashing the game --- .../common/wrappers/gui/ClassicConfigGUI.java | 10 +++++++--- coreSubProjects | 2 +- gradle.properties | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 762aac1e2..1de52eb6a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -118,14 +118,18 @@ public class ClassicConfigGUI */ private static void textField(AbstractConfigType info, Function func, Pattern pattern, boolean cast) { - boolean isNumber = pattern != null; ((EntryInfo) info.guiValue).widget = (BiFunction>) (editBox, button) -> stringValue -> { + boolean isNumber = (pattern != null); + stringValue = stringValue.trim(); if (!(stringValue.isEmpty() || !isNumber || pattern.matcher(stringValue).matches())) + { return false; + } - Number value = 0; + + Number value = info.typeIsFloatingPointNumber() ? 0.0 : 0; // different default values are needed so implicit casting works correctly (if not done casting from 0 (an int) to a double will cause an exception) ((EntryInfo) info.guiValue).error = null; if (isNumber && !stringValue.isEmpty() && !stringValue.equals("-") && !stringValue.equals(".")) { @@ -157,7 +161,7 @@ public class ClassicConfigGUI } ((EntryInfo) info.guiValue).tempValue = stringValue; - editBox.setTextColor(((ConfigEntry) info).isValid(value) == 0 ? 0xFFFFFFFF : 0xFFFF7777); + editBox.setTextColor(((ConfigEntry) info).isValid(value) == 0 ? 0xFFFFFFFF : 0xFFFF7777); // white and red // button.active = entries.stream().allMatch(e -> e.inLimits); diff --git a/coreSubProjects b/coreSubProjects index 8a6126665..127ec81ad 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 8a612666511f0b093117c57ec5cb394a0e555db5 +Subproject commit 127ec81adeba783cb5a90c56add2422b65ad39b3 diff --git a/gradle.properties b/gradle.properties index 2512c190e..b11590aa6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -48,7 +48,7 @@ versionStr= # This defines what MC version Intellij will use for the preprocessor # and what version is used automatically by build and run commands -mcVer=1.21.3 +mcVer=1.20.1 # Defines the maximum amount of memory Minecraft is allowed when run in a development environment #minecraftMemoryJavaArg="-Xmx4G"