Skip to content

Export a material list

Export the workshop's construction items as CSV for a spreadsheet or JSON for another script. The bill includes 49 stone bricks, 49 oak slabs, 12 oak logs, one red bed, one chest, one furnace, and one crafting table. Placement quantities count the two-block bed as a single item and exclude the chest's stored 64 stone.

Download materials.py and workshop.schem into one directory, then run:

uv run --with mcschemora materials.py workshop.schem --output output/materials

Choose a separate output directory for another build, since rerunning replaces the reports. The four files provide construction counts, expanded ingredients, and value estimates:

File Contents
materials.csv Seven construction item types and their quantities.
raw-materials.csv Fractional ingredients after recipe expansion.
materials.json Both views, keyed by canonical item ID.
values.json EMC and EssentialsX totals, including unpriced materials.

Report files

material_cost() returns items and raw_materials dictionaries, which the script writes with Python's standard json and csv modules. The example caps binary NBT decompression at 64 MiB and raises an error if catalogs or recipes are missing:

materials.py
import argparse
import csv
import json
from pathlib import Path

from mcschemora import Schematic


def main():
    parser = argparse.ArgumentParser(description="Export construction materials and values.")
    parser.add_argument("source", type=Path)
    parser.add_argument("--output", type=Path, default=Path("output/materials"))
    args = parser.parse_args()
    scene = Schematic.load(args.source, max_unpacked_bytes=64 * 1024 * 1024)
    materials = scene.material_cost()
    values = {profile: scene.value_cost(profile) for profile in ("emc", "essentialsx")}
    args.output.mkdir(parents=True, exist_ok=True)
    (args.output / "materials.json").write_text(json.dumps(materials, indent=2) + "\n")
    (args.output / "values.json").write_text(json.dumps(values, indent=2) + "\n")
    for field, filename in (("items", "materials.csv"), ("raw_materials", "raw-materials.csv")):
        with (args.output / filename).open("w", newline="") as output:
            writer = csv.writer(output)
            writer.writerow(("item", "quantity"))
            writer.writerows(sorted(materials[field].items()))
    for diagnostic in scene.import_diagnostics:
        print(diagnostic)
    print(f"Construction item types: {len(materials['items'])}")
    for profile, report in values.items():
        print(f"{profile}: {report['total']}; unpriced: {report['unpriced']}")
    print(f"Saved material reports to {args.output}")


if __name__ == "__main__":
    main()

Before using the expanded quantities for a gathering plan, interpret the raw ingredients. The materials and costs chapter explains construction counts, recipe expansion, and valuation.