minecraft_java_rs_core/models/
loader.rs1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
9#[serde(rename_all = "lowercase")]
10pub enum LoaderType {
11 Forge,
12 NeoForge,
13 Fabric,
14 LegacyFabric,
16 Quilt,
17}
18
19impl std::fmt::Display for LoaderType {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 let s = match self {
22 LoaderType::Forge => "forge",
23 LoaderType::NeoForge => "neoforge",
24 LoaderType::Fabric => "fabric",
25 LoaderType::LegacyFabric => "legacyfabric",
26 LoaderType::Quilt => "quilt",
27 };
28 f.write_str(s)
29 }
30}
31
32#[derive(Debug, Deserialize, Serialize)]
38pub struct LoaderLibrary {
39 pub name: String,
40 #[serde(default)]
42 pub url: Option<String>,
43 pub downloads: Option<LoaderLibraryDownloads>,
44 #[serde(default)]
46 pub rules: Option<Vec<Value>>,
47 #[serde(default)]
49 pub clientreq: Option<bool>,
50}
51
52#[derive(Debug, Deserialize, Serialize)]
53pub struct LoaderLibraryDownloads {
54 pub artifact: Option<LoaderArtifact>,
55}
56
57#[derive(Debug, Deserialize, Serialize)]
58pub struct LoaderArtifact {
59 pub sha1: Option<String>,
60 pub size: Option<u64>,
61 pub path: Option<String>,
62 pub url: String,
63}
64
65#[derive(Debug, Deserialize)]
69pub struct FabricMeta {
70 pub game: Vec<FabricGameVersion>,
71 pub loader: Vec<FabricLoaderBuild>,
72}
73
74#[derive(Debug, Deserialize)]
75pub struct FabricGameVersion {
76 pub version: String,
77 pub stable: bool,
78}
79
80#[derive(Debug, Deserialize)]
81pub struct FabricLoaderBuild {
82 pub version: String,
83 pub stable: bool,
84}
85
86#[derive(Debug, Deserialize)]
88pub struct QuiltLoaderBuild {
89 pub version: String,
90 #[serde(default)]
91 pub stable: bool,
92}
93
94#[derive(Debug, Deserialize)]
95pub struct QuiltMeta {
96 pub game: Vec<FabricGameVersion>,
97 pub loader: Vec<QuiltLoaderBuild>,
98}
99
100#[derive(Debug, Deserialize, Serialize)]
103#[serde(rename_all = "camelCase")]
104pub struct FabricJson {
105 pub id: String,
106 #[serde(default)]
107 pub libraries: Vec<LoaderLibrary>,
108 pub main_class: Option<String>,
109 pub minecraft_arguments: Option<String>,
110 #[serde(flatten)]
111 pub extra: HashMap<String, Value>,
112}
113
114#[derive(Debug, Clone, Deserialize, Serialize, Default)]
121pub struct ProfileDataEntry {
122 pub client: String,
123 #[serde(default)]
124 pub server: Option<String>,
125}
126
127#[derive(Debug, Deserialize, Serialize, Default)]
129pub struct ForgeArguments {
130 #[serde(default)]
131 pub game: Vec<serde_json::Value>,
132 #[serde(default)]
133 pub jvm: Vec<serde_json::Value>,
134}
135
136#[derive(Debug, Deserialize, Serialize, Default)]
140#[serde(default)]
141pub struct ForgeProfile {
142 pub install: Option<ForgeInstallSection>,
143 pub version: Option<ForgeVersionSection>,
144 pub data: Option<HashMap<String, ProfileDataEntry>>,
147 pub file_path: Option<String>,
149 pub path: Option<String>,
151 pub processors: Option<Vec<ForgeProcessor>>,
152 pub libraries: Option<Vec<LoaderLibrary>>,
153 #[serde(rename = "versionInfo", default)]
155 pub version_info: Option<ForgeVersionSection>,
156}
157
158#[derive(Debug, Deserialize, Serialize, Default)]
159#[serde(rename_all = "camelCase", default)]
160pub struct ForgeInstallSection {
161 pub libraries: Option<Vec<LoaderLibrary>>,
162 pub json: Option<String>,
164 pub path: Option<String>,
165 pub file_path: Option<String>,
166 pub minecraft: Option<String>,
167 pub processors: Option<Vec<ForgeProcessor>>,
168 #[serde(flatten)]
169 pub extra: HashMap<String, Value>,
170}
171
172#[derive(Debug, Deserialize, Serialize, Default)]
173#[serde(rename_all = "camelCase", default)]
174pub struct ForgeVersionSection {
175 pub id: Option<String>,
176 pub libraries: Option<Vec<LoaderLibrary>>,
177 pub main_class: Option<String>,
178 pub minecraft_arguments: Option<String>,
179 pub arguments: Option<ForgeArguments>,
181 #[serde(flatten)]
182 pub extra: HashMap<String, Value>,
183}
184
185#[derive(Debug, Deserialize, Serialize)]
187pub struct ForgeProcessor {
188 pub jar: String,
189 pub classpath: Vec<String>,
190 pub args: Vec<String>,
191 #[serde(default)]
192 pub sides: Option<Vec<String>>,
193}
194
195#[derive(Debug)]
199pub struct InstallerInfo {
200 pub file_path: String,
201 pub meta_data: String,
202 pub ext: String,
203 pub id: String,
204 pub old_api: bool,
206}