-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathusage.html
More file actions
306 lines (264 loc) · 11.8 KB
/
usage.html
File metadata and controls
306 lines (264 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Legacy Fabric - Usage</title>
<meta property="og:site_name" content="Legacy Fabric - Usage">
<meta property="og:title" content="Legacy Fabric">
<meta property="og:url" content="https://legacyfabric.net/usage.html">
<meta property="og:image" content="https://legacyfabric.net/res/img/logo.png">
<meta property="og:type" content="website">
<meta property="og:locale" content="en_US">
<meta property="og:description" content="The home of legacy version support for Fabric.">
<link href="res/css/main.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark-dimmed.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/gradle.min.js"></script>
</head>
<body onload="loadVersions(); showVersion('1.8.9');">
<nav>
<a class="main-nav" href="/">
<img src="res/img/logo.png" alt="" width="32" height="32">
Legacy Fabric
</a>
<a href="/downloads.html">Downloads</a>
<a href="/usage.html">Usage</a>
<a href="/mods.html">Mods</a>
<a href="https://github.com/Legacy-Fabric/">Source</a>
<a href="/discord">Discord</a>
<a href="https://status.legacyfabric.net">Status</a>
</nav>
<div class="page-content">
<h1>Usage</h1>
<label for="version-select">Minecraft Version:</label>
<select id="version-select" onchange="showVersion(this.value);"></select>
<h2>Latest Versions</h2>
<div class="latest-version">
<div name="code">
<h3>build.gradle</h3>
<pre><code class="gradle hljs"><span class="hljs-keyword">dependencies</span> {
minecraft <span class="hljs-string" id="full-version">"com.mojang:minecraft:{minecraft_version}"</span>
mappings <span class="hljs-string" id="full-mapping">"net.legacyfabric:yarn:{mappings_version}:v2"</span>
modImplementation <span class="hljs-string" id="full-loader">"net.fabricmc:fabric-loader:{loader_version}"</span><span id="full-api-section" hidden>
// Legacy-Fabric API
modImplementation <span class="hljs-string" id="full-api">"net.legacyfabric.legacy-fabric-api:legacy-fabric-api:{api_version}"</span></span>
}</code></pre>
</div>
<div name="code">
<h3>gradle.properties</h3>
<pre><code class="properties hljs"> <span class="hljs-attr">minecraft_version</span>=<span class="hljs-string" id="properties-version">{minecraft_version}</span>
<span class="hljs-attr">yarn_build</span>=<span class="hljs-string" id="properties-mapping">{mappings_build}</span>
<span class="hljs-attr">loader_version</span>=<span class="hljs-string" id="properties-loader">{loader_version}</span>
<span class="hljs-attr">loom_version</span>=<span class="hljs-string" id="properties-loom">1.11-SNAPSHOT</span><span id="properties-api-section" hidden>
# Legacy Fabric API
<span class="hljs-attr">fabric_version</span>=<span class="hljs-string" id="properties-api">{api_version}</span></span>
</code></pre>
</div>
</div>
<h2>Mappings Diff</h2>
<br>
<div class="diff">
<label for="mapping-select-1">From Mappings Build:</label>
<select id="mapping-select-1" onchange="updateFromMappings(this.value);"></select>
<br>
<label for="mapping-select-2">To Mappings Build:</label>
<select id="mapping-select-2" onchange="updateToMappings(this.value);"></select>
<h3>Classes</h3>
<div id="diff-classes"></div>
<h3>Fields</h3>
<div id="diff-fields"></div>
<h3>Methods</h3>
<div id="diff-methods"></div>
</div>
</div>
</body>
<script>
const fallbackMapping = "551";
const fallbackLoader = "0.16.10";
const fallbackApi = "1.11.1";
const fallbackSupportedApi = ["1.12.2","1.11.2","1.10.2","1.9.4","1.8.9","1.8","1.7.10","1.6.4"];
const emptyVersionInfos = {
loader: {
maven: "net.fabricmc:fabric-loader:" + fallbackLoader,
version: fallbackLoader,
},
mappings: {
build: "{mappings_build}",
maven: "net.legacyfabric:yarn:{mappings_version}",
version: "{mappings_version}",
}
};
const defaultVersionInfos = {
loader: {
maven: "net.fabricmc:fabric-loader:" + fallbackLoader,
version: fallbackLoader,
},
mappings: {
build: fallbackMapping,
maven: "net.legacyfabric:yarn:",
version: "",
}
};
let fromMappings = null;
let toMappings = null;
function loadVersions() {
fetch("https://meta.legacyfabric.net/v1/versions/game")
.then(function(response) {
return response.json();
}).then(function(json) {
let newHtml = "";
for (const versionData of json) {
const version = versionData.version;
const selected = version === "1.8.9" ? " selected" : "";
newHtml += `<option value="${version}" ${selected}>${version}</option>`;
}
document.getElementById("version-select").innerHTML = newHtml;
}).catch(function(error) {
console.error("Couldn't retrieve version list", error);
});
}
function renderLoaderAndMappings(versionInfos) {
document.getElementById("full-mapping").innerHTML = '"' + versionInfos.mappings.maven + ':v2"';
document.getElementById("full-loader").innerHTML = '"' + versionInfos.loader.maven + '"';
document.getElementById("properties-mapping").innerHTML = versionInfos.mappings.build;
document.getElementById("properties-loader").innerHTML = versionInfos.loader.version;
}
function renderApi(apiVersion) {
if (apiVersion != null) {
document.getElementById("full-api-section").hidden = false;
document.getElementById("properties-api-section").hidden = false;
document.getElementById("full-api").innerHTML = "net.legacyfabric.legacy-fabric-api:legacy-fabric-api:" + apiVersion;
document.getElementById("properties-api").innerHTML = apiVersion;
} else {
document.getElementById("full-api-section").hidden = true;
document.getElementById("properties-api-section").hidden = true;
}
}
function showVersion(version) {
document.getElementById("full-version").innerHTML = '"com.mojang:minecraft:' + version + '"';
document.getElementById("properties-version").innerHTML = version;
renderLoaderAndMappings(emptyVersionInfos);
if (fallbackSupportedApi.includes(version)) {
renderApi(fallbackApi + "+" + version);
} else {
renderApi(null);
}
fetch("https://meta.legacyfabric.net/v1/versions/loader/" + version)
.then(function(response) {
return response.json();
}).then(function(json) {
if (json.length > 0) {
const versionInfos = json[0];
renderLoaderAndMappings(versionInfos);
}
}).catch(function(error) {
console.error("Couldn't retrieve mappings and loader list, using fallbacks", error);
const fallbackMappingsVersion = version + "+build." + defaultVersionInfos.mappings.build;
renderLoaderAndMappings({
...defaultVersionInfos,
mappings: {
...defaultVersionInfos.mappings,
maven: defaultVersionInfos.mappings.maven + fallbackMappingsVersion,
version: fallbackMappingsVersion,
}
})
});
fetch("https://api.modrinth.com/v2/project/legacy-fabric-api/version")
.then(function(response) {
return response.json();
}).then(function(json) {
const filtered = json.filter(function(apiVersion) {
return apiVersion.game_versions.includes(version);
});
if (filtered.length > 0) {
renderApi(filtered[0].version_number + "+" + version);
}
}).catch(function(error) {
console.error("Couldn't retrieve api version list", error);
})
fetch("https://meta.legacyfabric.net/v2/versions/yarn/" + version)
.then(function(response) {
return response.json();
}).then(function (json) {
let newHtml = "";
for (const versionData of json) {
newHtml += `<option value="${versionData.version}">${versionData.build}</option>`;
}
document.getElementById("mapping-select-1").innerHTML = newHtml;
document.getElementById("mapping-select-2").innerHTML = newHtml;
fromMappings = toMappings = json[0].version;
})
.catch(function(error) {
console.error("Couldn't retrieve yarn version list", error);
});
}
function renderDiff(diff) {
let classHtml = `<ul>`;
for (const classEntry of diff.classes) {
classHtml += `<li>${classEntry.source} -> ${classEntry.target}</li>`;
}
classHtml += "</ul>";
document.getElementById("diff-classes").innerHTML = classHtml;
let fieldHtml = ``;
const groupedFields = Object.groupBy(diff.fields, ({ owner }) => owner);
for (const [owner, fields] of Object.entries(groupedFields)) {
fieldHtml += `<h4>${owner}</h4>`;
fieldHtml += `<ul>`;
for (const field of fields) {
fieldHtml += `<li>${field.source} -> ${field.target}</li>`
}
fieldHtml += "</ul>";
}
document.getElementById("diff-fields").innerHTML = fieldHtml;
let methodHtml = ``;
const groupedMethods = Object.groupBy(diff.methods, ({owner}) => owner);
for (const [owner, methods] of Object.entries(groupedMethods)) {
methodHtml += `<h4>${owner}</h4>`;
methodHtml += `<ul>`;
for (const method of methods) {
methodHtml += `
<li>
${method.source} ${method.sourceDesc}<br>
-> ${method.target} ${method.targetDesc}
</li>`
}
methodHtml += "</ul>";
}
document.getElementById("diff-methods").innerHTML = methodHtml;
}
function updateFromMappings(version) {
if (fromMappings === version) {
return;
}
fromMappings = version;
if (fromMappings === toMappings || toMappings === null) return;
fetch("https://meta.legacyfabric.net/v2/diff/" + fromMappings + "/" + toMappings)
.then(function(response) {
return response.json();
})
.then(function(json) {
renderDiff(json);
})
.catch(function(error) {
console.error("Couldn't retrieve diff", error);
});
}
function updateToMappings(version) {
if (toMappings === version) {
return;
}
toMappings = version;
if (fromMappings === toMappings || fromMappings === null) return;
fetch("https://meta.legacyfabric.net/v2/diff/" + fromMappings + "/" + toMappings)
.then(function(response) {
return response.json();
})
.then(function(json) {
renderDiff(json);
})
.catch(function(error) {
console.error("Couldn't retrieve diff", error);
});
}
</script>
</html>