diff --git a/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java b/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java index a251aecee..4b6d201b9 100644 --- a/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java @@ -57,6 +57,7 @@ import net.neoforged.neoforge.registries.RegistryBuilder; import javax.annotation.Nullable; +import java.nio.file.Path; @Mod(ComputerCraftAPI.MOD_ID) @EventBusSubscriber(modid = ComputerCraftAPI.MOD_ID, bus = EventBusSubscriber.Bus.MOD) @@ -175,7 +176,13 @@ public static void sync(ModConfigEvent.Reloading event) { private static void syncConfig(ModConfig config) { if (!config.getModId().equals(ComputerCraftAPI.MOD_ID)) return; - var path = config.getFullPath(); + Path path; + try { + path = config.getFullPath(); + } catch (IllegalStateException ignored) { + path = null; // getFullPath throws if loading a non-valid file. + } + if (config.getType() == ModConfig.Type.SERVER && ((ForgeConfigFile) ConfigSpec.serverSpec).spec().isLoaded()) { ConfigSpec.syncServer(path); } else if (config.getType() == ModConfig.Type.CLIENT) {