{"record":{"id":"273ccc430aaaf55b","repo":"HMCL-dev/HMCL","slug":"level-dat-missing-data","errorCode":null,"errorMessage":"level.dat missing Data","messagePattern":"level\\.dat missing Data","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/game/World.java","lineNumber":247,"sourceCode":"    }\n\n    public boolean supportQuickPlay() {\n        return getGameVersion() != null && getGameVersion().isAtLeast(\"1.20\", \"23w14a\");\n    }\n\n    public static boolean supportQuickPlay(GameVersionNumber gameVersionNumber) {\n        return gameVersionNumber != null && gameVersionNumber.isAtLeast(\"1.20\", \"23w14a\");\n    }\n\n    private void loadAndCheckWorldData() throws IOException {\n        loadAndCheckLevelData(levelDataPath);\n        loadOtherData();\n    }\n\n    private void loadAndCheckLevelData(Path levelDat) throws IOException {\n        this.levelData = NBTCodec.of().readTag(levelDat, TagType.COMPOUND);\n        if (!(levelData.get(\"Data\") instanceof CompoundTag data))\n            throw new IOException(\"level.dat missing Data\");\n\n        if (!(data.get(\"LevelName\") instanceof StringTag))\n            throw new IOException(\"level.dat missing LevelName\");\n\n        if (!(data.get(\"LastPlayed\") instanceof LongTag))\n            throw new IOException(\"level.dat missing LastPlayed\");\n        this.dataTag = data;\n    }\n\n    private void loadOtherData() throws IOException {\n        if (!(levelData.get(\"Data\") instanceof CompoundTag data)) return;\n\n        Path worldGenSettingsDatPath = file.resolve(\"data/minecraft/world_gen_settings.dat\");\n        if (data.get(\"WorldGenSettings\") instanceof CompoundTag worldGenSettingsTag) {\n            setWorldGenSettingsData(null, worldGenSettingsTag, worldGenSettingsTag);\n        } else if (Files.isRegularFile(worldGenSettingsDatPath)) {\n            CompoundTag raw = NBTCodec.of().readTag(worldGenSettingsDatPath, TagType.COMPOUND);\n            if (raw.get(\"data\") instanceof CompoundTag compoundTag) {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/game/World.java#L229-L265","documentation":"Thrown by loadAndCheckLevelData after parsing level.dat: the root NBT compound has no 'Data' child compound tag. Vanilla Minecraft always stores world metadata under Data, so its absence means the file is corrupt or not a real level.dat.","triggerScenarios":"Calling new World(worldDir) or loadAndCheckWorldData on a level.dat whose decompressed NBT root lacks the Data compound tag.","commonSituations":"A level.dat corrupted by a crash or disk failure, a truncated download/copy, a zero-byte or placeholder level.dat created by a faulty backup tool, or hand-crafted NBT files used in tests.","solutions":["Restore level.dat from a backup of the world","Re-copy the world from the source Minecraft installation","Verify level.dat is gzip-compressed NBT with a root compound containing Data (inspect with an NBT editor)","If the file is truncated (size 0 or far below ~800 bytes), regenerate the world or accept data loss"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Decompress and sanity-check before constructing World:\n// gzip -t level.dat succeeds and the file is at least a few hundred bytes\nstatic boolean levelDatPlausible(Path dir) throws IOException {\n    Path ld = dir.resolve(\"level.dat\");\n    return Files.isRegularFile(ld) && Files.size(ld) > 0;\n}","typeGuard":"static boolean hasLevelData(Path worldDir) {\n    return Files.isRegularFile(worldDir.resolve(\"level.dat\"));\n}","tryCatchPattern":"try {\n    World world = new World(worldDir);\n} catch (IOException e) {\n    if (String.valueOf(e.getMessage()).equals(\"level.dat missing Data\")) {\n        // restore from backup or notify user the world metadata is corrupt\n    }\n}","preventionTips":["Keep world backups; level.dat corruption is unrecoverable without one","Shut down Minecraft cleanly before copying worlds","Avoid editing level.dat with tools that rewrite NBT without validating tag types","Check copied world size matches source after transfer"],"tags":["minecraft","nbt","corruption","world"],"backgroundTag":"schema-validation-failed","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}