{"record":{"id":"0263605ffe891609","repo":"HMCL-dev/HMCL","slug":"level-dat-missing-lastplayed","errorCode":null,"errorMessage":"level.dat missing LastPlayed","messagePattern":"level\\.dat missing LastPlayed","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/game/World.java","lineNumber":253,"sourceCode":"    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) {\n                setWorldGenSettingsData(worldGenSettingsDatPath, raw, compoundTag);\n            } else {\n                setWorldGenSettingsData(null, null, null);\n            }\n        } else {\n            setWorldGenSettingsData(null, null, null);","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/game/World.java#L235-L271","documentation":"Thrown by loadAndCheckLevelData when level.dat's Data compound lacks a 'LastPlayed' LongTag. HMCL displays and sorts worlds by their last-played timestamp, so a missing or wrong-typed LastPlayed makes the world data incomplete.","triggerScenarios":"new World(worldDir) on a level.dat where Data.LastPlayed is absent or stored as a non-Long tag (e.g. Int or String).","commonSituations":"level.dat hand-edited or rebuilt by third-party tools omitting LastPlayed, corrupted metadata after a crash, minimal hand-crafted NBT fixtures in tests, or conversions between world formats.","solutions":["Set Data.LastPlayed as a LongTag (epoch milliseconds) with an NBT editor","Restore level.dat from backup","Re-copy the world from a working Minecraft instance","Fix test/generator code to write LastPlayed with putLong"],"exampleFix":"// before\ndataTag.putString(\"LastPlayed\", \"1700000000000\"); // wrong type\n// after\ndataTag.putLong(\"LastPlayed\", 1700000000000L);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    World world = new World(worldDir);\n} catch (IOException e) {\n    if (String.valueOf(e.getMessage()).equals(\"level.dat missing LastPlayed\")) {\n        // set LastPlayed via NBT editor or treat as unsupported world\n    }\n}","preventionTips":["Write LastPlayed as a LongTag (epoch millis) in any tooling that generates level.dat","Avoid lossy converters that rewrite Data compound types","Keep a pristine backup before letting third-party tools touch level.dat"],"tags":["minecraft","nbt","world","validation"],"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"}