{"record":{"id":"78ac687435ace347","repo":"Anuken/Mindustry","slug":"missing-a-valid-block-in-requirements","errorCode":null,"errorMessage":"Missing a valid 'block' in 'requirements'","messagePattern":"Missing a valid 'block' in 'requirements'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/mod/ContentParser.java","lineNumber":656,"sourceCode":"            }\n\n            currentContent = unit;\n            read(() -> {\n                unit.beforeParse();\n                //add reconstructor type\n                if(value.has(\"requirements\")){\n                    JsonValue rec = value.remove(\"requirements\");\n\n                    UnitReq req = parser.readValue(UnitReq.class, rec);\n\n                    if(req.block instanceof Reconstructor r){\n                        if(req.previous != null){\n                            r.upgrades.add(new UnitType[]{req.previous, unit});\n                        }\n                    }else if(req.block instanceof UnitFactory f){\n                        f.plans.add(new UnitPlan(unit, req.time, req.requirements));\n                    }else{\n                        throw new IllegalArgumentException(\"Missing a valid 'block' in 'requirements'\");\n                    }\n                }\n\n                if(value.has(\"controller\") || value.has(\"aiController\")){\n                    unit.aiController = resolveController(value.getString(\"controller\", value.getString(\"aiController\", \"\")));\n                    value.remove(\"controller\");\n                }\n\n                if(value.has(\"defaultController\")){\n                    var sup = resolveController(value.getString(\"defaultController\"));\n                    unit.controller = u -> sup.get();\n                    value.remove(\"defaultController\");\n                }\n\n                //read extra default waves\n                if(value.has(\"waves\")){\n                    JsonValue waves = value.remove(\"waves\");\n                    SpawnGroup[] groups = parser.readValue(SpawnGroup[].class, waves);","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/mod/ContentParser.java#L638-L674","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Set \"requirements.block\" to the internal name of an existing Reconstructor or UnitFactory.","Verify the referenced block is loaded before this unit (check load order / dependencies).","Remove the \"requirements\" section if this unit is not produced by a factory."],"exampleFix":"// before\n\"requirements\": { \"block\": \"copper-wall-large\", \"time\": 60 }\n// after\n\"requirements\": { \"block\": \"ground-factory\", \"time\": 60 }","handlingStrategy":"validation","validationCode":"// Confirm requirements.block resolves to a production block before parse.\nif(value.has(\"requirements\")){\n    String bname = value.get(\"requirements\").getString(\"block\", \"\");\n    Block b = Vars.content.block(currentMod != null ? currentMod.name + \"-\" + bname : bname);\n    if(b == null) b = Vars.content.block(bname);\n    if(!(b instanceof Reconstructor) && !(b instanceof UnitFactory)){\n        throw new IllegalStateException(\"requirements.block must be a Reconstructor or UnitFactory: \" + bname);\n    }\n}","typeGuard":"boolean isProducer(Block b){ return b instanceof Reconstructor || b instanceof UnitFactory; }","tryCatchPattern":null,"preventionTips":["Only point requirements at factories/reconstructors.","Confirm the referenced block loads first."],"tags":["mindustry","modding","json","content-parser","unit","requirements"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}