From 1a0117445cbfde116ff3921552b0d2a11c4e75e8 Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Sun, 20 Oct 2024 00:57:03 +0200 Subject: [PATCH] Serialize custom water format with JsonUtil. --- .../java/se/llbit/chunky/renderer/scene/Scene.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java index e9f5ff5a2..50077803a 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java @@ -2568,11 +2568,7 @@ public void setUseCustomWaterColor(boolean value) { json.add("waterVisibility", waterVisibility); json.add("useCustomWaterColor", useCustomWaterColor); if (useCustomWaterColor) { - JsonObject colorObj = new JsonObject(); - colorObj.add("red", waterColor.x); - colorObj.add("green", waterColor.y); - colorObj.add("blue", waterColor.z); - json.add("waterColor", colorObj); + json.add("waterColor", JsonUtil.rgbToJson(waterColor)); } currentWaterShader.save(json); json.add("fog", fog.toJson()); @@ -2877,10 +2873,7 @@ else if(waterShader.equals("SIMPLEX")) waterVisibility = json.get("waterVisibility").doubleValue(waterVisibility); useCustomWaterColor = json.get("useCustomWaterColor").boolValue(useCustomWaterColor); if (useCustomWaterColor) { - JsonObject colorObj = json.get("waterColor").object(); - waterColor.x = colorObj.get("red").doubleValue(waterColor.x); - waterColor.y = colorObj.get("green").doubleValue(waterColor.y); - waterColor.z = colorObj.get("blue").doubleValue(waterColor.z); + JsonUtil.rgbFromJson(json.get("waterColor"), waterColor); } biomeColors = json.get("biomeColorsEnabled").boolValue(biomeColors); transparentSky = json.get("transparentSky").boolValue(transparentSky);