diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-08-11 03:03:00 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-08-11 03:03:08 +0800 |
| commit | 87bb1a6bf154648919b437d31266899fbc9baaff (patch) | |
| tree | 9ce734ee0cc4e726d5d1859a0163c1fc272a3b39 /runtime/src/main/java/me/shedaniel | |
| parent | 0b4e0878df5d670c49567d5fb90d6cfbdaa05bad (diff) | |
| download | RoughlyEnoughItems-87bb1a6bf154648919b437d31266899fbc9baaff.tar.gz RoughlyEnoughItems-87bb1a6bf154648919b437d31266899fbc9baaff.tar.bz2 RoughlyEnoughItems-87bb1a6bf154648919b437d31266899fbc9baaff.zip | |
Fix crash without architectury api
Diffstat (limited to 'runtime/src/main/java/me/shedaniel')
| -rw-r--r-- | runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java | 16 |
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); } } |
