Browse Source

We ditch the NEC api because it depends on mc 1.15.x

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 5 years ago
parent
commit
312bb1d912

+ 0 - 2
build.gradle

@@ -55,8 +55,6 @@ dependencies {
 
     modImplementation "io.github.prospector:modmenu:${modmenu_version}"
 
-    modApi "com.lettuce.fudge:notenoughcrashes-api:1.0.0"
-    include "com.lettuce.fudge:notenoughcrashes-api:1.0.0"
     modRuntime "com.lettuce.fudge:notenoughcrashes:$nec_version"
 }
 

+ 1 - 1
gradle.properties

@@ -2,6 +2,6 @@ minecraft_version=1.15.1
 yarn_mappings=1.15.1+build.37
 loader_version=0.7.4+build.177
 fabric_version=0.4.28+build.288-1.15
-mod_version=2.9.2
+mod_version=2.9.3
 modmenu_version=1.8.4+build.20
 nec_version=1.2.3+1.15.1

+ 12 - 5
src/main/java/me/shedaniel/clothconfig2/impl/ScissorsHandlerImpl.java

@@ -1,10 +1,11 @@
 package me.shedaniel.clothconfig2.impl;
 
 import com.google.common.collect.Lists;
-import fudge.notenoughcrashes.api.MinecraftCrashes;
 import me.shedaniel.clothconfig2.ClothConfigInitializer;
 import me.shedaniel.clothconfig2.api.ScissorsHandler;
+import me.shedaniel.math.api.Executor;
 import me.shedaniel.math.api.Rectangle;
+import net.fabricmc.loader.api.FabricLoader;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.util.Window;
 import org.lwjgl.opengl.GL11;
@@ -17,11 +18,17 @@ public final class ScissorsHandlerImpl implements ScissorsHandler {
     @Deprecated public static final ScissorsHandler INSTANCE = new ScissorsHandlerImpl();
     
     static {
-        MinecraftCrashes.onEveryCrash(() -> {
+        Executor.runIf(() -> FabricLoader.getInstance().isModLoaded("notenoughcrashes"), () -> () -> {
             try {
-                ScissorsHandler.INSTANCE.clearScissors();
-            } catch (Throwable t) {
-                ClothConfigInitializer.LOGGER.error("[ClothConfig] Failed clear scissors on game crash!", t);
+                Class.forName("fudge.notenoughcrashes.api.NotEnoughCrashesApi").getDeclaredMethod("onEveryCrash", Runnable.class).invoke(null, (Runnable) () -> {
+                    try {
+                        ScissorsHandler.INSTANCE.clearScissors();
+                    } catch (Throwable t) {
+                        ClothConfigInitializer.LOGGER.error("[ClothConfig] Failed clear scissors on game crash!", t);
+                    }
+                });
+            } catch (Throwable throwable) {
+                throwable.printStackTrace();
             }
         });
     }