Anuken/Mindustry · error · IllegalArgumentException

Type not found: ${base}

Error message

Type not found: ${base}

What it means

When resolving a 'type' string to a Java class, ContentParser tries arc., mindustry., then the mod classloader, and finally a provided default. If no class is found and no default (def) was supplied, it throws IllegalArgumentException 'Type not found: <base>'. This maps JSON type names to concrete content classes.

Source

Thrown at core/src/mindustry/mod/ContentParser.java:1457

        if(out != null) return (Class<T>)out;

        //try to resolve it as a raw class name
        if(base.indexOf('.') != -1 && allowClassResolution){
            try{
                return (Class<T>)Class.forName(base);
            }catch(Exception ignored){
                //try to use mod class loader
                try{
                    return (Class<T>)Class.forName(base, true, mods.mainLoader());
                }catch(Exception ignore){}
            }
        }

        if(def != null){
            if(warn) warn("[@] No type '" + base + "' found, defaulting to type '" + def.getSimpleName() + "'", currentFile != null ? currentFile : currentMod != null ? currentMod.name : "");
            return def;
        }
        throw new IllegalArgumentException("Type not found: " + base);
    }

    void warn(String string, Object... format){
        warnContext(currentContent, currentFile, string, format);
    }

    void warnContext(@Nullable Content currentContent, @Nullable Fi currentFile, String string, Object... format){
        Log.warn(string, format);
    }

    void onNewInstance(Object object, Class<?> type){}

    public Json getJson(){
        checkInit();
        return parser;
    }

    private interface FieldParser{

View on GitHub (pinned to f695ad7e60)

Solutions

  1. Verify the exact fully-qualified or simple name in the 'type' field against a real class.
  2. Ensure custom classes are compiled into the mod jar and on the mod classloader.
  3. Check game version compatibility for the class you reference.
  4. Use a known vanilla type string as a sanity check.

Example fix

// before
{ "type": "mindustry.world.blocks.Turret", "name": "x" }

// after (real vanilla block subclass)
{ "type": "Turret", "name": "x" }
Defensive patterns

Strategy: validation

Validate before calling

// Check a type string resolves before parsing content that needs it.
Class<?> c = null;
try { c = Class.forName(typeName, false, mods.mainLoader()); } catch(ClassNotFoundException ignored) {}
if(c == null) throw new IllegalArgumentException("Unknown content type: " + typeName);

Type guard

boolean typeResolves(String name){
    try { Class.forName(name, false, mods.mainLoader()); return true; }
    catch(ClassNotFoundException e){ return false; }
}

Try / catch

try {
    parser.resolveType(base, def, warn);
} catch(IllegalArgumentException e) {
    if(e.getMessage().startsWith("Type not found")) { /* prompt user to fix type string */ }
    else throw e;
}

Prevention

When it happens

Trigger: A mod JSON 'type' field names a class that does not exist on the classpath or is misspelled, and the parser was not given a fallback type.

Common situations: Typo in the type string; mod references a class added in a newer/older game version; custom content class not packaged in the mod jar; wrong package prefix.

Related errors


AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14). Data as JSON: /api/errors/61628e89b0e19f26. Report an issue: GitHub.