aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/manifest.rs
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2026-01-18 12:39:09 +0800
committerGitHub <noreply@github.com>2026-01-18 12:39:09 +0800
commitd78520b74ee7b01db633035c9c8d33ee809ba04d (patch)
tree30b888202a82a28dbd480340ab231af411037913 /src-tauri/src/core/manifest.rs
parent6d82ab2275130f3bafdb7ec664297eb700321526 (diff)
parent373fb81604451f085bf9fbccf9251acb17e400a9 (diff)
downloadDropOut-d78520b74ee7b01db633035c9c8d33ee809ba04d.tar.gz
DropOut-d78520b74ee7b01db633035c9c8d33ee809ba04d.zip
Merge pull request #57 from HsiangNianian/fix/critical-bugs
Diffstat (limited to 'src-tauri/src/core/manifest.rs')
-rw-r--r--src-tauri/src/core/manifest.rs37
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, &current_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