|
25 | 25 | import com.falsepattern.lib.internal.FPLog; |
26 | 26 | import lombok.NoArgsConstructor; |
27 | 27 | import lombok.val; |
| 28 | +import org.jetbrains.annotations.NotNull; |
| 29 | +import org.jetbrains.annotations.Nullable; |
28 | 30 |
|
29 | 31 | import net.minecraft.client.Minecraft; |
30 | 32 | import net.minecraft.client.gui.GuiScreen; |
@@ -56,10 +58,9 @@ public static void init() { |
56 | 58 | try { |
57 | 59 | MODS_FIELD = GuiModList.class.getDeclaredField("mods"); |
58 | 60 | MODS_FIELD.setAccessible(true); |
59 | | - } catch (NoSuchFieldException e) { |
60 | | - MODS_FIELD = null; |
| 61 | + } catch (Throwable t) { |
61 | 62 | 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); |
63 | 64 | return; |
64 | 65 | } |
65 | 66 | MinecraftForge.EVENT_BUS.register(new InGameModOptionsFix()); |
@@ -92,17 +93,19 @@ private GuiModConfigList(GuiScreen screen) { |
92 | 93 | } |
93 | 94 |
|
94 | 95 | private List<ModContainer> getModsFromPrivateField() { |
| 96 | + assert MODS_FIELD != null; |
95 | 97 | try { |
96 | 98 | return (List<ModContainer>) MODS_FIELD.get(this); |
97 | | - } catch (Exception e) { |
| 99 | + } catch (Throwable t) { |
98 | 100 | return Collections.emptyList(); |
99 | 101 | } |
100 | 102 | } |
101 | 103 |
|
102 | 104 | private void setModsToPrivateField(List<ModContainer> mods) { |
| 105 | + assert MODS_FIELD != null; |
103 | 106 | try { |
104 | 107 | MODS_FIELD.set(this, mods); |
105 | | - } catch (Exception ignored) { |
| 108 | + } catch (Throwable ignored) { |
106 | 109 | } |
107 | 110 | } |
108 | 111 | } |
|
0 commit comments