Anuken/Mindustry · error · IllegalArgumentException
Mod is not loaded yet (or missing)!
Error message
Mod is not loaded yet (or missing)!
What it means
Mods.getConfigFolder maps a Mod instance to its ModMeta via the metas registry. If no meta is registered for that mod class, it means the mod has not finished loading/registration yet, and an IllegalArgumentException is thrown. getConfig() delegates here.
Source
Thrown at core/src/mindustry/mod/Mods.java:71
Seq<LoadedMod> mods = new Seq<>();
private Seq<LoadedMod> newImports = new Seq<>();
private ObjectMap<Class<?>, ModMeta> metas = new ObjectMap<>();
private boolean requiresReload;
public Mods(){
Events.on(ClientLoadEvent.class, e -> Core.app.post(this::checkWarnings));
}
/** @return the main class loader for all mods */
public ClassLoader mainLoader(){
return mainLoader;
}
/** @return the folder where configuration files for this mod should go. Call this in init(). */
public Fi getConfigFolder(Mod mod){
ModMeta load = metas.get(mod.getClass());
if(load == null) throw new IllegalArgumentException("Mod is not loaded yet (or missing)!");
Fi result = modDirectory.child(load.name);
result.mkdirs();
return result;
}
/** @return a file named 'config.json' in the config folder for the specified mod.
* Call this in init(). */
public Fi getConfig(Mod mod){
return getConfigFolder(mod).child("config.json");
}
/** Returns a list of files per mod subdirectory. */
public void listFiles(String directory, Cons2<LoadedMod, Fi> cons){
eachEnabled(mod -> {
Fi file = mod.root.child(directory);
if(file.exists()){
for(Fi child : file.list()){
if(!child.isDirectory()){View on GitHub (pinned to f695ad7e60)
Solutions
- Move all getConfig()/getConfigFolder() calls into the mod's init() method (documented requirement).
- Ensure you call getConfig on the actual loaded Mod instance, not a fresh one.
- Do not access config during class construction or static init.
Example fix
// before
public class MyMod extends Mod {
public MyMod() {
Fi cfg = getConfig(); // throws: not loaded yet
}
}
// after
public class MyMod extends Mod {
@Override
public void init() {
Fi cfg = getConfig();
}
} Defensive patterns
Strategy: validation
Validate before calling
// Only fetch config once the mod is registered.
if(!mods.getMods().anyMatch(m -> m.main == this)) {
throw new IllegalStateException("getConfig called before mod registration; move to init().");
}
Fi cfg = getConfig(); Try / catch
try {
Fi cfg = getConfig();
} catch(IllegalArgumentException e) {
if(e.getMessage().equals("Mod is not loaded yet (or missing)!")) { /* defer to init() */ }
else throw e;
} Prevention
- Never call getConfig()/getConfigFolder() in the mod constructor or static init.
- Perform all config I/O in init().
- Call getConfig on the loaded instance, not a newly constructed one.
When it happens
Trigger: A mod calls getConfigFolder/getConfig from its constructor or any callback that runs before the mod is registered in the metas map.
Common situations: Mod reads config in its constructor instead of init(); plugin instantiated outside the normal load flow; calling getConfig on a mod object that is not the loaded instance.
Related errors
- Calling getPixmap outside of createIcons is not supported!
- Error loading mod {mod.meta.name}
- No constructor set up for unit '@': Assign `constructor = [y
- No constructor set up for unit '{name}', add this argument t
- Two content objects defined with the same name: '{content.na
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/cd2d6205cf157218.
Report an issue: GitHub.