Skip to content

Commit ba44631

Browse files
committed
Carbon Config compat
1 parent 97e326e commit ba44631

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/java/com/cleanroommc/catalogue/client/CleanroomModData.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.jetbrains.annotations.NotNull;
2020
import org.jetbrains.annotations.Nullable;
2121

22+
import java.lang.reflect.Method;
2223
import java.util.*;
2324
import java.util.stream.Collectors;
2425

@@ -170,6 +171,7 @@ public Set<String> getChildMods() {
170171

171172
@Override
172173
public boolean hasConfig() {
174+
ensureCarbonConfigsRegistered();
173175
IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(this.info);
174176
if (guiFactory == null) return false;
175177
return guiFactory.hasConfigGui();
@@ -186,6 +188,20 @@ public void openConfigScreen(Minecraft minecraft, GuiScreen parent) {
186188
}
187189
}
188190

191+
private static boolean carbonConfigRegistrationAttempted;
192+
193+
private static void ensureCarbonConfigsRegistered() {
194+
if (carbonConfigRegistrationAttempted) return;
195+
carbonConfigRegistrationAttempted = true;
196+
try {
197+
Class<?> cls = Class.forName("carbonconfiglib.impl.internal.EventHandler");
198+
Method m = cls.getDeclaredMethod("registerConfigs");
199+
m.setAccessible(true);
200+
m.invoke(cls.getField("INSTANCE").get(null));
201+
} catch (ReflectiveOperationException | LinkageError ignored) {
202+
}
203+
}
204+
189205
@Override
190206
public void drawUpdateIcon(Minecraft minecraft, Update update, int x, int y) {
191207
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

0 commit comments

Comments
 (0)