aboutsummaryrefslogtreecommitdiffstats
path: root/src/minecraft/manifests.rs
diff options
context:
space:
mode:
authorFilip Wandzio <contact@philw.dev>2026-01-24 08:29:14 +0100
committerFilip Wandzio <contact@philw.dev>2026-01-24 08:29:14 +0100
commita393e0a2f2c3678a3ea869dc1417fa269f2b1040 (patch)
tree606df6a9284b5bd2dbf84fa5e3d363b8e6a01322 /src/minecraft/manifests.rs
parent72ddd7b7704f2087a52c9c0552446682918c513b (diff)
downloaddml-a393e0a2f2c3678a3ea869dc1417fa269f2b1040.tar.gz
dml-a393e0a2f2c3678a3ea869dc1417fa269f2b1040.zip
Resolve audio not loading bug
Ensure all assets are downloading for each version Temporarily disable minecraft versions older than 1.8 because of the asset/manifest loading issues Implement basic documentation of modules Implement basic async/multithreading for downloading assets
Diffstat (limited to 'src/minecraft/manifests.rs')
-rw-r--r--src/minecraft/manifests.rs43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/minecraft/manifests.rs b/src/minecraft/manifests.rs
index 3cc59af..8bdec26 100644
--- a/src/minecraft/manifests.rs
+++ b/src/minecraft/manifests.rs
@@ -1,4 +1,7 @@
1#![allow(dead_code)] 1#![allow(dead_code)]
2
3use std::collections::HashMap;
4
2use reqwest; 5use reqwest;
3use serde::Deserialize; 6use serde::Deserialize;
4 7
@@ -13,6 +16,17 @@ pub struct Version {
13 16
14 pub downloads: Downloads, 17 pub downloads: Downloads,
15 pub libraries: Vec<Library>, 18 pub libraries: Vec<Library>,
19
20 #[serde(rename = "assetIndex")]
21 pub asset_index: Option<AssetIndex>,
22}
23
24#[derive(Debug, Deserialize)]
25pub struct AssetIndex {
26 pub id: String,
27 pub sha1: String,
28 pub size: u64,
29 pub url: String,
16} 30}
17 31
18#[derive(Debug, Deserialize)] 32#[derive(Debug, Deserialize)]
@@ -29,12 +43,22 @@ pub struct DownloadInfo {
29 43
30#[derive(Debug, Deserialize)] 44#[derive(Debug, Deserialize)]
31pub struct Library { 45pub struct Library {
46 pub name: Option<String>,
32 pub downloads: LibraryDownloads, 47 pub downloads: LibraryDownloads,
48
49 #[serde(default)]
50 pub natives: Option<HashMap<String, String>>,
51
52 #[serde(default)]
53 pub rules: Option<Vec<Rule>>,
33} 54}
34 55
35#[derive(Debug, Deserialize)] 56#[derive(Debug, Deserialize)]
36pub struct LibraryDownloads { 57pub struct LibraryDownloads {
37 pub artifact: Option<LibraryArtifact>, 58 pub artifact: Option<LibraryArtifact>,
59
60 #[serde(default)]
61 pub classifiers: Option<HashMap<String, LibraryArtifact>>,
38} 62}
39 63
40#[derive(Debug, Deserialize)] 64#[derive(Debug, Deserialize)]
@@ -45,7 +69,20 @@ pub struct LibraryArtifact {
45 pub size: u64, 69 pub size: u64,
46} 70}
47 71
48pub async fn load_version(cfg: &crate::config::Config) -> Result<Version, McError> { 72#[derive(Debug, Deserialize)]
73pub struct Rule {
74 pub action: String,
75 pub os: Option<OsRule>,
76}
77
78#[derive(Debug, Deserialize)]
79pub struct OsRule {
80 pub name: String,
81}
82
83pub async fn load_version(
84 cfg: &crate::config::Config,
85) -> Result<Version, McError> {
49 let manifest_text = reqwest::get(VERSION_MANIFEST_URL) 86 let manifest_text = reqwest::get(VERSION_MANIFEST_URL)
50 .await? 87 .await?
51 .text() 88 .text()
@@ -67,7 +104,9 @@ pub async fn load_version(cfg: &crate::config::Config) -> Result<Version, McErro
67 let version_entry = versions 104 let version_entry = versions
68 .iter() 105 .iter()
69 .find(|v| v["id"].as_str() == Some(&version_id)) 106 .find(|v| v["id"].as_str() == Some(&version_id))
70 .ok_or_else(|| McError::Config(format!("version '{}' not found", version_id)))?; 107 .ok_or_else(|| {
108 McError::Config(format!("version '{}' not found", version_id))
109 })?;
71 110
72 let url = version_entry["url"] 111 let url = version_entry["url"]
73 .as_str() 112 .as_str()