Skip to content

WIP: gen2 feather diff #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions public/feather_diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ import {
import * as tiny from "./tiny_mappings.js";

(async () => {
const minecraftStableVersions = await getMinecraftStableVersions("gen1");
const minecraftAllVersions = await getMinecraftVersions("gen1");
let minecraftStableVersions = await getMinecraftStableVersions("gen1");
let minecraftAllVersions = await getMinecraftVersions("gen1");

let possibleVersions;

const genSelectorRadios = {
gen1: document.getElementById("generation-gen1"),
gen2: document.getElementById("generation-gen2")
}

const versionSelectorInput = document.getElementById("mc-version");
const versionListElement = document.getElementById("version-list");
const allowSnapshotsCheck = document.getElementById("allow-snapshots");
const featherGenSelector = document.getElementById("calamus-gen-selectors");

const buildSourceElement = document.getElementById("build-source");
const buildTargetElement = document.getElementById("build-target");
Expand All @@ -29,7 +35,8 @@ import * as tiny from "./tiny_mappings.js";
if (
possibleVersions.some((version) => versionSelectorInput.value === version)
) {
await getFeatherVersionMeta("gen1", versionSelectorInput.value).then(
const gen = Object.entries(genSelectorRadios).find(([_, button]) => button.checked)[0];
await getFeatherVersionMeta(gen, versionSelectorInput.value).then(
(featherVersionMeta) => {
buildSourceElement.innerHTML = "";
buildTargetElement.innerHTML = "";
Expand All @@ -47,11 +54,16 @@ import * as tiny from "./tiny_mappings.js";

// Hide the diff viewer bc the source and target builds are the same
diffViewerElement.style.display = "none";
} else {
buildSourceElement.innerHTML = "";
buildTargetElement.innerHTML = "";
diffViewerElement.style.display = "none";
}
}

async function getTinyMappings(version) {
let arrayBuf = await getFeatherBuildMaven(version)
const gen = Object.entries(genSelectorRadios).find(([_, button]) => button.checked)[0];
let arrayBuf = await getFeatherBuildMaven(gen, version)
.then((response) => response.blob()) // Get response as a Blob
.then(async (blob) => {
const arrayBuffer = await blob.arrayBuffer(); // Convert Blob to ArrayBuffer
Expand Down Expand Up @@ -142,14 +154,17 @@ import * as tiny from "./tiny_mappings.js";
);

allowSnapshotsCheck.addEventListener("change", (_) => {
if (allowSnapshotsCheck.checked) {
possibleVersions = minecraftAllVersions;
} else {
possibleVersions = minecraftStableVersions;
}
updateVersionList();
});

featherGenSelector.addEventListener("change", async (e) => {
const gen = Object.entries(genSelectorRadios).find(([_, button]) => button === e.target)[0];
minecraftStableVersions = await getMinecraftStableVersions(gen);
minecraftAllVersions = await getMinecraftVersions(gen);

updateVersionList();
})

buildSourceElement.addEventListener(
"change",
async (_) => await updateFeatherDiff(),
Expand All @@ -165,17 +180,21 @@ import * as tiny from "./tiny_mappings.js";
});

function updateVersionList() {
const list = possibleVersions;
if (allowSnapshotsCheck.checked) {
possibleVersions = minecraftAllVersions;
} else {
possibleVersions = minecraftStableVersions;
}

while (versionListElement.firstChild)
versionListElement.removeChild(versionListElement.lastChild);
list.forEach((e) => {
possibleVersions.forEach((e) => {
const opt = new Option();
opt.value = e;
versionListElement.appendChild(opt);
});
}

possibleVersions = minecraftStableVersions;
updateVersionList();
await updateFeatherBuilds();
})();
18 changes: 16 additions & 2 deletions public/meta_maven_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,21 @@ function makeOrnitheMavenUrl(...pathComponents) {
return makeMavenUrl("net/ornithemc", ...pathComponents);
}

export async function getFeatherBuildMaven(version) {
const url = makeOrnitheMavenUrl("feather", version, "feather-" + version + "-tiny.gz");
export async function getFeatherBuildMaven(ornitheGen, version) {
let feather;
switch (ornitheGen) {
case "gen1": {
feather = "feather";
break;
}
case "gen2": {
feather = "feather-gen2";
break;
}
default: {
throw new Error("Invalid generation: " + ornitheGen);
}
}
const url = makeOrnitheMavenUrl(feather, version, "feather-" + version + "-tiny.gz");
return await fetch(url);
}
9 changes: 9 additions & 0 deletions src/pages/featherDiff.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ import Layout from "../layouts/Layout.astro";
<label for="allow-snapshots">Include Snapshots</label>
</fieldset>

<fieldset id="calamus-gen-selectors">
<legend>Select a Calamus (Intermediary) Generation</legend>
<input type="radio" id="generation-gen1" name="calamus-generation" checked />
<label for="generation-gen1">Gen1</label>

<input type="radio" id="generation-gen2" name="calamus-generation" />
<label for="generation-gen2">Gen2</label>
</fieldset>

<label for="mc-version">Game version</label>
<input type="text" id="mc-version" list="version-list" value="1.7.2" />
<datalist id="version-list">
Expand Down