Anuken/Mindustry · error · IllegalArgumentException
Unit stances must be strings.
Error message
Unit stances must be strings.
What it means
Thrown by the UnitStance parser when data is not a string. Stances resolve only by name, so object/number/array values are rejected before any lookup.
Source
Thrown at core/src/mindustry/mod/ContentParser.java:176
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) -> {
if(data.isString()){
return field(Bullets.class, data);
}else if(data.isArray()){
return new MultiBulletType(parser.readValue(BulletType[].class, data));
}
Class<?> alternate = resolve(Strings.capitalize(data.getString("type", "basic")) + "BulletType", Object.class, false);
Class<?> bc = alternate == Object.class ? resolve(data.getString("type", ""), BasicBulletType.class) : alternate;
data.remove("type");
BulletType result = (BulletType)make(bc);
result.minfo.mod = currentMod;
readFields(result, data);
return result;
});
put(MassDriverBolt.class, (type, data) -> {
MassDriverBolt result = make(MassDriverBolt.class);View on GitHub (pinned to f695ad7e60)
Solutions
- Provide the stance as a quoted string.
- Use a registered stance name.
Example fix
// before
"stance": { "name": "stop" }
// after
"stance": "stop" Defensive patterns
Strategy: type-guard
Type guard
// Guard: unit stance value must be a JSON string.
boolean isStanceRef(JsonValue v) { return v.isString(); } Prevention
- Always quote stance name strings.
- Avoid object syntax for stance references.
- Lint JSON value types in mod files.
When it happens
Trigger: A mod JSON supplies a unit stance field as a non-string JSON value.
Common situations: Missing quotes around the stance name, or attempting object-style configuration not supported for stances.
Related errors
- Unknown unit stance name:
- Attribute definitions must be objects, e.g. {heat: 10}
- Unknown status effect: '
- Unknown unit command name:
- Unit commands must be strings.
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/7de636f6669f28ae.
Report an issue: GitHub.