Anuken/Mindustry · error · IllegalArgumentException

Unknown unit command name:

Error message

Unknown unit command name: 

What it means

Thrown by the UnitCommand parser when data is a string but content.unitCommand(name) returns null, i.e. no command with that name is registered. Commands are referenced by name wherever a unit/command config uses a string.

Source

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

        });
        put(StatusEffect.class, (type, data) -> {
            if(data.isString()){
                StatusEffect result = locate(ContentType.status, data.asString());
                if(result != null) return result;
                throw new IllegalArgumentException("Unknown status effect: '" + data.asString() + "'");
            }
            StatusEffect effect = new StatusEffect((currentMod == null ? null : currentMod.name + "-") + data.getString("name"));
            effect.minfo.mod = currentMod;
            readFields(effect, data);
            return effect;
        });
        put(UnitCommand.class, (type, data) -> {
            if(data.isString()){
               var cmd = content.unitCommand(data.asString());
               if(cmd != null){
                   return cmd;
               }else{
                   throw new IllegalArgumentException("Unknown unit command name: " + data.asString());
               }
            }else{
                throw new IllegalArgumentException("Unit commands must be strings.");
            }
        });
        put(UnitStance.class, (type, data) -> {
            if(data.isString()){
                var cmd = content.unitStance(data.asString());
                if(cmd != null){
                    return cmd;
                }else{
                    throw new IllegalArgumentException("Unknown unit stance name: " + data.asString());
                }
            }else{
                throw new IllegalArgumentException("Unit stances must be strings.");
            }
        });
        put(BulletType.class, (type, data) -> {

View on GitHub (pinned to f695ad7e60)

Solutions

  1. Verify the exact command name against the registered unit commands.
  2. Confirm the running game version supports that command.
  3. Check load order if the command comes from another mod.

Example fix

// before
"command": "moveto"
// after
"command": "moveTo"
Defensive patterns

Strategy: validation

Validate before calling

// Verify a unit command name is registered.
boolean commandExists(String name) {
    return Vars.content.unitCommand(name) != null;
}

Prevention

When it happens

Trigger: A mod JSON references a unit command by a string name that does not exist in the command registry.

Common situations: Typo in the command name, command added in a different game version, or referencing a command from a not-yet-loaded mod.

Related errors


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