Skip to content

Commit

Permalink
Add usage page
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Feb 22, 2025
1 parent c9aa19b commit 405c9ae
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea/
7 changes: 5 additions & 2 deletions downloads.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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>
Expand All @@ -35,11 +36,13 @@ <h2>Installers</h2>
<a href="https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/0.11.1/fabric-installer-0.11.1.exe" id="installer-exe"><button class="download-button">Download .exe <br> (for windows)</button></a>
<a href="https://maven.legacyfabric.net/net/legacyfabric/fabric-installer/0.11.1/fabric-installer-0.11.1.jar" id="installer-jar"><button class="download-button">Download .jar <br> (universal)</button></a>
<a href="https://github.com/Legacy-Fabric/multimc-instance-creator/releases"><button class="download-button">MultiMC <br> instances</button></a>
</div>
</div>
</body>
<script>
var fallback = "0.11.1"
const fallback = "0.11.1"
function setLatestMeta() {
var latest
let latest
fetch("https://meta.legacyfabric.net/v2/versions/installer")
.then(function(response) {
return response.json()
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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>
Expand Down
1 change: 1 addition & 0 deletions mods.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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>
Expand Down
4 changes: 4 additions & 0 deletions res/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ ul, ol {
li::marker {
font-weight: bold;
}

pre {
text-align: left;
}
181 changes: 181 additions & 0 deletions usage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Legacy Fabric - Downloads</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/downloads.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 href="res/css/downloads.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">
<label for="version-select">Minecraft Version:</label>
<select id="version-select" onchange="showVersion(this.value);"></select>

<h3>build.gradle</h3>
<div name="code">
<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>
<h3>gradle.properties</h3>
<div name="code">
<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 id="properties-api-section" hidden><span class="hljs-attr">fabric_version</span>=<span class="hljs-string" id="properties-api">{api_version}</span></span>
</code></pre>
</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: "",
}
};

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);
})
}
</script>
</html>

0 comments on commit 405c9ae

Please sign in to comment.