0 Recovering corrupt NBT files (MCA Schematic etc.)
NotMyFault edited this page 2018-12-18 21:18:28 +01:00

Note: Please contact me (ticket, discord etc.) if you need help recovering files.

If a file in NBT format is partially corrupt, some data can often be recovered. So long as the compression header is intact (if it's a compressed file) and a tag's name is still intact. For GZIP, the compression trailer does not need to be present.

Included in FAWE is the CorruptSchematicReader for recovering corrupt schematic, however the method can be adapted for MCA files or other NBT based formats.

Here is a snippet where it matches the Width tag and sets the width variable.

match("Width", new CorruptSchematicStreamer.CorruptReader() {
    @Override
    public void run(DataInputStream in) throws IOException {
        width.set(in.readShort());
    }
});

There's also a method where it tries to guess the schematic dimensions based on the data length if some of the dimension tags are missing: Vector guessDimensions(int volume, int width, int height, int length)