]> git.lizzy.rs Git - LightOverlay.git/commitdiff
Update Cloth Config
authorshedaniel <daniel@shedaniel.me>
Fri, 24 Apr 2020 03:06:23 +0000 (11:06 +0800)
committershedaniel <daniel@shedaniel.me>
Fri, 24 Apr 2020 03:06:23 +0000 (11:06 +0800)
build.gradle
src/main/java/me/shedaniel/lightoverlay/LightOverlayCloth.java
src/main/resources/META-INF/mods.toml

index e50699d851a85d3f2c9fcba39e82867d5f096e06..9d194a44ffd13d57eebb39a51d1b79a84cf3f061 100644 (file)
@@ -16,7 +16,7 @@ plugins {
 apply plugin: 'net.minecraftforge.gradle'
 apply plugin: 'eclipse'
 
-version = "4.4"
+version = "4.5"
 group = "me.shedaniel" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
 archivesBaseName = "LightOverlay"
 
@@ -58,7 +58,7 @@ repositories {
 
 dependencies {
     minecraft 'net.minecraftforge:forge:1.15.2-31.1.39'
-    implementation fg.deobf("curse.maven:cloth-config-forge:2844737")
+    implementation fg.deobf("curse.maven:cloth-config-forge:2938583")
 }
 
 jar {
index 48aec5ce87bfaa99a01571a5f10602236f122927..71b72b1790d8b3bef7797ae6fc702f87930659d1 100644 (file)
@@ -3,14 +3,10 @@ package me.shedaniel.lightoverlay;
 import me.shedaniel.forge.clothconfig2.api.ConfigBuilder;
 import me.shedaniel.forge.clothconfig2.api.ConfigCategory;
 import me.shedaniel.forge.clothconfig2.api.ConfigEntryBuilder;
-import net.minecraft.client.resources.I18n;
 import net.minecraft.util.math.MathHelper;
 import net.minecraftforge.fml.ExtensionPoint;
 import net.minecraftforge.fml.ModLoadingContext;
 
-import java.util.Locale;
-import java.util.Optional;
-
 public class LightOverlayCloth {
     public static void register() {
         ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (client, parent) -> {
@@ -22,18 +18,8 @@ public class LightOverlayCloth {
             general.addEntry(eb.startIntSlider("config.lightoverlay-forge.crossLevel", LightOverlayClient.crossLevel, 0, 15).setDefaultValue(7).setTextGetter(integer -> "Cross Level: " + integer).setSaveConsumer(integer -> LightOverlayClient.crossLevel = integer).build());
             general.addEntry(eb.startBooleanToggle("config.lightoverlay-forge.showNumber", LightOverlayClient.showNumber).setDefaultValue(false).setSaveConsumer(bool -> LightOverlayClient.showNumber = bool).build());
             general.addEntry(eb.startIntSlider("config.lightoverlay-forge.lineWidth", MathHelper.floor(LightOverlayClient.lineWidth * 100), 100, 700).setDefaultValue(100).setTextGetter(integer -> "Light Width: " + LightOverlayClient.FORMAT.format(integer / 100d)).setSaveConsumer(integer -> LightOverlayClient.lineWidth = integer / 100f).build());
-            general.addEntry(eb.startStrField("config.lightoverlay-forge.yellowColor", "#" + toStringColor(LightOverlayClient.yellowColor)).setDefaultValue("#FFFF00").setSaveConsumer(str -> LightOverlayClient.yellowColor = toIntColor(str)).setErrorSupplier(s -> {
-                if (!s.startsWith("#") || s.length() != 7 || !isInt(s.substring(1)))
-                    return Optional.of(I18n.format("config.lightoverlay-forge.invalidColor"));
-                else
-                    return Optional.empty();
-            }).build());
-            general.addEntry(eb.startStrField("config.lightoverlay-forge.redColor", "#" + toStringColor(LightOverlayClient.redColor)).setDefaultValue("#FF0000").setSaveConsumer(str -> LightOverlayClient.redColor = toIntColor(str)).setErrorSupplier(s -> {
-                if (!s.startsWith("#") || s.length() != 7 || !isInt(s.substring(1)))
-                    return Optional.of(I18n.format("config.lightoverlay-forge.invalidColor"));
-                else
-                    return Optional.empty();
-            }).build());
+            general.addEntry(eb.startColorField("config.lightoverlay-forge.yellowColor", LightOverlayClient.yellowColor).setDefaultValue(0xFFFF00).setSaveConsumer(color -> LightOverlayClient.yellowColor = color).build());
+            general.addEntry(eb.startColorField("config.lightoverlay-forge.redColor", LightOverlayClient.redColor).setDefaultValue(0xFF0000).setSaveConsumer(color -> LightOverlayClient.redColor = color).build());
             
             return builder.setSavingRunnable(() -> {
                 try {
@@ -45,34 +31,4 @@ public class LightOverlayCloth {
             }).build();
         });
     }
-    
-    private static boolean isInt(String s) {
-        try {
-            Integer.parseInt(s, 16);
-            return true;
-        } catch (NumberFormatException e) {
-            return false;
-        }
-    }
-    
-    private static int toIntColor(String str) {
-        String substring = str.substring(1);
-        int r = Integer.parseInt(substring.substring(0, 2), 16);
-        int g = Integer.parseInt(substring.substring(2, 4), 16);
-        int b = Integer.parseInt(substring.substring(4, 6), 16);
-        return (r << 16) + (g << 8) + b;
-    }
-    
-    private static String toStringColor(int toolColor) {
-        String r = Integer.toHexString((toolColor >> 16) & 0xFF);
-        String g = Integer.toHexString((toolColor >> 8) & 0xFF);
-        String b = Integer.toHexString(toolColor & 0xFF);
-        if (r.length() == 1)
-            r = "0" + r;
-        if (g.length() == 1)
-            g = "0" + g;
-        if (b.length() == 1)
-            b = "0" + b;
-        return (r + g + b).toUpperCase(Locale.ROOT);
-    }
 }
index a6785fd265bd57cf8b3551f776b18f62fdb7ff4a..a6d7f031f5160b1bf1ee30b0f257729dbc6f5d1f 100755 (executable)
@@ -38,7 +38,7 @@ To provide users with NEI-like light overlay.
     # Does this dependency have to exist - if not, ordering below must be specified
     mandatory=true #mandatory
     # The version range of the dependency
-    versionRange="[2.0,)" #mandatory
+    versionRange="[3.0,)" #mandatory
     ordering="NONE"
     # Side this dependency is applied on - BOTH, CLIENT or SERVER
     side="CLIENT"