aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-08-11 03:03:00 +0800
committershedaniel <daniel@shedaniel.me>2023-05-29 21:15:03 +0800
commit2bab59166f1e8580c20c755cb716e12be5f72a9c (patch)
tree7368ae4a884fa4432e5471dae1231d89d75aa42f /runtime/src/main/java
parent55eaf2f871acc45a0ce234d72103e48e4adab25a (diff)
downloadRoughlyEnoughItems-2bab59166f1e8580c20c755cb716e12be5f72a9c.tar.gz
RoughlyEnoughItems-2bab59166f1e8580c20c755cb716e12be5f72a9c.tar.bz2
RoughlyEnoughItems-2bab59166f1e8580c20c755cb716e12be5f72a9c.zip
Fix crash without architectury api
Diffstat (limited to 'runtime/src/main/java')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java
index 1b4bbdb61..29b7accfe 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java
@@ -23,13 +23,12 @@
package me.shedaniel.rei.impl.client;
-import dev.architectury.platform.Platform;
import me.shedaniel.rei.RoughlyEnoughItemsState;
import me.shedaniel.rei.impl.client.gui.screen.WarningAndErrorScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
-import java.lang.reflect.InvocationTargetException;
+import java.util.ServiceLoader;
import java.util.function.UnaryOperator;
public class ErrorDisplayer {
@@ -56,12 +55,11 @@ public class ErrorDisplayer {
}
public static void registerGuiInit(UnaryOperator<Screen> consumer) {
- try {
- Class.forName("me.shedaniel.rei.impl.client.%s.ErrorDisplayerImpl".formatted(Platform.isForge() ? "forge" : "fabric"))
- .getDeclaredMethod("registerGuiInit", UnaryOperator.class)
- .invoke(null, consumer);
- } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
+ ErrorGuiInitializer initializer = ServiceLoader.load(ErrorGuiInitializer.class).findFirst().orElseThrow();
+ initializer.registerGuiInit(consumer);
+ }
+
+ public interface ErrorGuiInitializer {
+ void registerGuiInit(UnaryOperator<Screen> consumer);
}
}