Skip to content

Commit c548db4

Browse files
committed
make ingame mod options more error resistant
1 parent d8b3659 commit c548db4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/com/falsepattern/lib/internal/config/InGameModOptionsFix.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import com.falsepattern.lib.internal.FPLog;
2626
import lombok.NoArgsConstructor;
2727
import lombok.val;
28+
import org.jetbrains.annotations.NotNull;
29+
import org.jetbrains.annotations.Nullable;
2830

2931
import net.minecraft.client.Minecraft;
3032
import net.minecraft.client.gui.GuiScreen;
@@ -56,10 +58,9 @@ public static void init() {
5658
try {
5759
MODS_FIELD = GuiModList.class.getDeclaredField("mods");
5860
MODS_FIELD.setAccessible(true);
59-
} catch (NoSuchFieldException e) {
60-
MODS_FIELD = null;
61+
} catch (Throwable t) {
6162
FPLog.LOG.error("Failed to get field: cpw.mods.fml.client.GuiModList.mods,"
62-
+ " In-Game Mod Options Fix will not work", e);
63+
+ " In-Game Mod Options Fix will not work", t);
6364
return;
6465
}
6566
MinecraftForge.EVENT_BUS.register(new InGameModOptionsFix());
@@ -92,17 +93,19 @@ private GuiModConfigList(GuiScreen screen) {
9293
}
9394

9495
private List<ModContainer> getModsFromPrivateField() {
96+
assert MODS_FIELD != null;
9597
try {
9698
return (List<ModContainer>) MODS_FIELD.get(this);
97-
} catch (Exception e) {
99+
} catch (Throwable t) {
98100
return Collections.emptyList();
99101
}
100102
}
101103

102104
private void setModsToPrivateField(List<ModContainer> mods) {
105+
assert MODS_FIELD != null;
103106
try {
104107
MODS_FIELD.set(this, mods);
105-
} catch (Exception ignored) {
108+
} catch (Throwable ignored) {
106109
}
107110
}
108111
}

0 commit comments

Comments
 (0)