{"record":{"id":"b6d744897c907b49","repo":"Anuken/Mindustry","slug":"invalid-schematic-too-many-blocks","errorCode":null,"errorMessage":"Invalid schematic: Too many blocks.","messagePattern":"Invalid schematic: Too many blocks\\.","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/game/Schematics.java","lineNumber":625,"sourceCode":"\n            String[] labels = null;\n\n            //try to read the categories, but skip if it fails\n            try{\n                labels = JsonIO.read(String[].class, map.get(\"labels\", \"[]\"));\n            }catch(Exception ignored){}\n\n            IntMap<Block> blocks = new IntMap<>();\n            int length = stream.readUnsignedByte();\n            for(int i = 0; i < length; i++){\n                String name = stream.readUTF();\n                Block block = Vars.content.getByName(ContentType.block, SaveFileReader.fallback.get(name, name));\n                blocks.put(i, block == null || block instanceof LegacyBlock ? Blocks.air : block);\n            }\n\n            int total = stream.readInt();\n\n            if(limitSchematicSize && total > 128 * 128) throw new IOException(\"Invalid schematic: Too many blocks.\");\n\n            Reads read = new Reads(stream);\n\n            Seq<Stile> tiles = new Seq<>(total);\n            for(int i = 0; i < total; i++){\n                Block block = blocks.get(stream.readByte());\n                int position = stream.readInt();\n                Object config = ver == 0 ? mapConfig(block, stream.readInt(), position) : TypeIO.readObject(read, false, mapper);\n                byte rotation = stream.readByte();\n                if(block != Blocks.air){\n                    tiles.add(new Stile(block, Point2.x(position), Point2.y(position), config, rotation));\n                }\n            }\n\n            Schematic out = new Schematic(tiles, map, width, height);\n            if(labels != null) out.labels.addAll(labels);\n            return out;\n        }","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/game/Schematics.java#L607-L643","documentation":"Thrown by Schematics.read when limitSchematicSize is enabled and the total block count read from the stream exceeds 128*128 (16384). This is the area-based cap complementing the dimension cap: even a small footprint schematic could in theory pack many blocks, so the total is bounded by the maximum grid area.","triggerScenarios":"A schematic whose 'total' field (stream.readInt()) is > 16384 with limitSchematicSize == true. Block count exceeding the 128x128 grid capacity.","commonSituations":"Densely packed schematics; schematics created by automation that exceed the block budget; combined/merged schematics that overflow.","solutions":["Reduce the block count (split or simplify the schematic) to <= 16384 tiles.","Set Schematics.limitSchematicSize = false if oversized schematics are intentional.","Re-export from a valid editor selection that fits the cap."],"exampleFix":"// before\nSchematic s = Schematics.read(input); // throws if total > 16384\n\n// after\nSchematics.limitSchematicSize = false;\nSchematic s = Schematics.read(input);","handlingStrategy":"validation","validationCode":"// if you know block count ahead of time\nif(limitSchematicSize && total > 128*128){\n    ui.showErrorMessage(\"Too many blocks (max \" + (128*128) + \")\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try{ Schematic s = Schematics.read(input); }catch(IOException e){ ui.showErrorMessage(\"Schematic has too many blocks\"); }","preventionTips":["Keep block counts under 16384 for compatibility.","Simplify or split dense schematics.","Catch IOException at the import boundary."],"tags":["schematic","limits","io","config"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}