diff options
| author | 2026-01-18 12:41:05 +0800 | |
|---|---|---|
| committer | 2026-01-18 12:41:05 +0800 | |
| commit | dbf781a35b96252e0199fec4337515651e49a8f6 (patch) | |
| tree | 30b888202a82a28dbd480340ab231af411037913 /src-tauri/src/core/manifest.rs | |
| parent | fd00ac6878b2cee9337b9e92d0c990ecdce9a346 (diff) | |
| parent | d78520b74ee7b01db633035c9c8d33ee809ba04d (diff) | |
| download | DropOut-dbf781a35b96252e0199fec4337515651e49a8f6.tar.gz DropOut-dbf781a35b96252e0199fec4337515651e49a8f6.zip | |
Merge pull request #59 from HsiangNianian/main
Diffstat (limited to 'src-tauri/src/core/manifest.rs')
| -rw-r--r-- | src-tauri/src/core/manifest.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src-tauri/src/core/manifest.rs b/src-tauri/src/core/manifest.rs index 637b935..e792071 100644 --- a/src-tauri/src/core/manifest.rs +++ b/src-tauri/src/core/manifest.rs @@ -97,6 +97,43 @@ pub async fn fetch_vanilla_version( Ok(resp) } +/// Find the root vanilla version by following the inheritance chain. +/// +/// For modded versions (Fabric, Forge), this walks up the `inheritsFrom` +/// chain to find the base vanilla Minecraft version. +/// +/// # Arguments +/// * `game_dir` - The .minecraft directory path +/// * `version_id` - The version ID to start from +/// +/// # Returns +/// The ID of the root vanilla version (the version without `inheritsFrom`) +pub async fn find_root_version( + game_dir: &std::path::Path, + version_id: &str, +) -> Result<String, Box<dyn Error + Send + Sync>> { + let mut current_id = version_id.to_string(); + + // Keep following the inheritance chain + loop { + let version = match load_local_version(game_dir, ¤t_id).await { + Ok(v) => v, + Err(_) => { + // If not found locally, assume it's a vanilla version (root) + return Ok(current_id); + } + }; + + // If this version has no parent, it's the root + if let Some(parent_id) = version.inherits_from { + current_id = parent_id; + } else { + // This is the root + return Ok(current_id); + } + } +} + /// Load a version, checking local first, then fetching from remote if needed. /// /// For modded versions (those with `inheritsFrom`), this will also resolve |