From 460a2189d66fb622f7a6d904e564fa034de3f985 Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 27 Apr 2017 19:02:50 -0700 Subject: [PATCH] Prevent NPE in ConfigManager and fix config gui being enabled for all mods. Fixes #3856. (#3860) --- .../net/minecraftforge/common/config/ConfigManager.java | 7 ++++++- .../net/minecraftforge/fml/client/FMLClientHandler.java | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraftforge/common/config/ConfigManager.java b/src/main/java/net/minecraftforge/common/config/ConfigManager.java index 34f2712ef..1cad0703b 100644 --- a/src/main/java/net/minecraftforge/common/config/ConfigManager.java +++ b/src/main/java/net/minecraftforge/common/config/ConfigManager.java @@ -202,7 +202,12 @@ public class ConfigManager public static Class[] getModConfigClasses(String modid) { - return MOD_CONFIG_CLASSES.get(modid).toArray(new Class[0]); + return (MOD_CONFIG_CLASSES.containsKey(modid) ? MOD_CONFIG_CLASSES.get(modid).toArray(new Class[0]) : new Class[0]); + } + + public static boolean hasConfigForMod(String modid) + { + return asm_data.containsKey(modid); } // ======================================================= diff --git a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java index 006c48334..dc3c98a33 100644 --- a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java +++ b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java @@ -83,6 +83,7 @@ import net.minecraft.world.storage.SaveFormatOld; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.ConfigManager; import net.minecraftforge.common.util.CompoundDataFixer; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.DummyModContainer; @@ -377,7 +378,10 @@ public class FMLClientHandler implements IFMLSidedHandler String className = mc.getGuiClassName(); if (Strings.isNullOrEmpty(className)) { - guiFactories.put(mc, DefaultGuiFactory.forMod(mc)); + if (ConfigManager.hasConfigForMod(mc.getModId())) + { + guiFactories.put(mc, DefaultGuiFactory.forMod(mc)); + } continue; } try