Anuken/Mindustry · error · IllegalArgumentException

Missing a valid 'block' in 'requirements'

Error message

Missing a valid 'block' in 'requirements'

What it means

A unit's "requirements" block is deserialized into a UnitReq, then req.block is checked: it must be either a Reconstructor (for upgrade chains) or a UnitFactory (for production plans). If req.block is neither — null, wrong block type, or unresolved — the parser cannot wire the unit into a production chain and throws.

Source

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

            }

            currentContent = unit;
            read(() -> {
                unit.beforeParse();
                //add reconstructor type
                if(value.has("requirements")){
                    JsonValue rec = value.remove("requirements");

                    UnitReq req = parser.readValue(UnitReq.class, rec);

                    if(req.block instanceof Reconstructor r){
                        if(req.previous != null){
                            r.upgrades.add(new UnitType[]{req.previous, unit});
                        }
                    }else if(req.block instanceof UnitFactory f){
                        f.plans.add(new UnitPlan(unit, req.time, req.requirements));
                    }else{
                        throw new IllegalArgumentException("Missing a valid 'block' in 'requirements'");
                    }
                }

                if(value.has("controller") || value.has("aiController")){
                    unit.aiController = resolveController(value.getString("controller", value.getString("aiController", "")));
                    value.remove("controller");
                }

                if(value.has("defaultController")){
                    var sup = resolveController(value.getString("defaultController"));
                    unit.controller = u -> sup.get();
                    value.remove("defaultController");
                }

                //read extra default waves
                if(value.has("waves")){
                    JsonValue waves = value.remove("waves");
                    SpawnGroup[] groups = parser.readValue(SpawnGroup[].class, waves);

View on GitHub (pinned to f695ad7e60)

Solutions

  1. Set "requirements.block" to the internal name of an existing Reconstructor or UnitFactory.
  2. Verify the referenced block is loaded before this unit (check load order / dependencies).
  3. Remove the "requirements" section if this unit is not produced by a factory.

Example fix

// before
"requirements": { "block": "copper-wall-large", "time": 60 }
// after
"requirements": { "block": "ground-factory", "time": 60 }
Defensive patterns

Strategy: validation

Validate before calling

// Confirm requirements.block resolves to a production block before parse.
if(value.has("requirements")){
    String bname = value.get("requirements").getString("block", "");
    Block b = Vars.content.block(currentMod != null ? currentMod.name + "-" + bname : bname);
    if(b == null) b = Vars.content.block(bname);
    if(!(b instanceof Reconstructor) && !(b instanceof UnitFactory)){
        throw new IllegalStateException("requirements.block must be a Reconstructor or UnitFactory: " + bname);
    }
}

Type guard

boolean isProducer(Block b){ return b instanceof Reconstructor || b instanceof UnitFactory; }

Prevention

When it happens

Trigger: The "requirements.block" field references a block name that resolves to something other than a Reconstructor or UnitFactory, or the referenced block does not exist (resolves to null).

Common situations: Typing the block name; pointing requirements at a non-production block (e.g. a turret or wall); referencing a block from a mod that loads later or not at all.

Related errors


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