diff --git a/_includes/tabbed_builscript.liquid b/_includes/tabbed_builscript.liquid
index 22ea2f00..7e2ef606 100644
--- a/_includes/tabbed_builscript.liquid
+++ b/_includes/tabbed_builscript.liquid
@@ -12,12 +12,15 @@
{%- if include.mods %}
{%- assign mods = include.mods %}
{%- else %}
-{%- assign mods = "" | split: "," | push: include.mod1 %}
+{%- assign mod1 = include.mod1 | split: ":" %}
+{%- assign mods = "" | split: "," | push: mod1 %}
{%- if include.mod2 %}
-{%- assign mods = mods | push: include.mod2 %}
+{%- assign mod2 = include.mod2 | split: ":" %}
+{%- assign mods = mods | push: mod2 %}
{%- endif %}
{%- if include.mod3 %}
-{%- assign mods = mods | push: include.mod3 %}
+{%- assign mod3 = include.mod3 | split: ":" %}
+{%- assign mods = mods | push: mod3 %}
{%- endif %}
{%- endif %}
{%- capture result %}
@@ -25,9 +28,19 @@
{%- endcapture %}
{% for mod in mods %}
{%- capture result %}
-{%- capture replacement_key %}<{% if mods.size > 1 %}{{ mod | upcase }}_{% endif %}VERSION>{% endcapture %}
-{%- capture replacement %}{{ replacement_key }}{% endcapture %}
+{%- capture replacement_key %}<{% if mods.size > 1 %}{{ mod[0] | upcase }}_{% endif %}VERSION>{% endcapture %}
+{%- capture replacement %}{{ replacement_key }}{% endcapture %}
{{ result | replace: replacement_key, replacement }}
{%- endcapture %}
{% endfor %}
+{% if mods.size > 0 and mods[0].size > 1 %}
+
+
+
+{% endif %}
{{ result }}
diff --git a/scripts/modrinth-api.js b/scripts/modrinth-api.js
index 72312172..6586b0e5 100644
--- a/scripts/modrinth-api.js
+++ b/scripts/modrinth-api.js
@@ -14,6 +14,10 @@ function handleRequestTask(req) {
});
}
+export const compareMcVersions = (a, b) => {
+ return b[1].mcVersion.releaseTime - a[1].mcVersion.releaseTime;
+};
+
/**
* @typedef {Object} ModrinthVersion
* @property {string} name
@@ -84,5 +88,5 @@ export async function getVersions(modrinthProjectId) {
isSnapshot: pistonMeta.get(id)?.type !== 'release',
},
modVersions: versions,
- }])).sort((a, b) => b[1].mcVersion.releaseTime - a[1].mcVersion.releaseTime));
+ }])).sort(compareMcVersions));
}
diff --git a/scripts/smart-buildscript.js b/scripts/smart-buildscript.js
index f3bd56f2..cd17d51d 100644
--- a/scripts/smart-buildscript.js
+++ b/scripts/smart-buildscript.js
@@ -1,4 +1,4 @@
-import { getVersions } from "./modrinth-api.js";
+import {compareMcVersions, getVersions} from "./modrinth-api.js";
/**
* @typedef {Object} McIndexedVersion
@@ -16,7 +16,7 @@ function pickDefaultVersion(versions) {
return versions.get(pinned);
}
- return versions[0];
+ return versions.values().next().value;
}
/**
@@ -36,15 +36,7 @@ function indexVersions(projectVersions) {
result.get(mcVersionId).modVersions.set(mod, modVersions);
}
}
- if (projectVersions.length > 1) {
- // iterate again to prune every version that is lacking one of the mods
- for (const [mcVersion, mods] of result) {
- if (mods.size < projectVersions.length) { // missing one or more mods
- result.delete(mcVersion);
- }
- }
- }
- return result;
+ return new Map([...result].sort(compareMcVersions));
}
function doReplace(modName, version = 'VERSION') {
@@ -55,35 +47,35 @@ function doReplace(modName, version = 'VERSION') {
/**
* @param {McIndexedVersion} version
+ * @param {string[]} mods
* @param {boolean?} pin
*/
-function selectVersion(version, pin) {
+function selectVersion(version, mods, pin) {
// update the window URL to include the selected version
- const state = history.state;
- const title = document.title;
if (pin) {
const url = new URL(window.location.href);
url.searchParams.set('version', version.mcVersion.id);
- history.replaceState(state, title, url);
+ history.replaceState(history.state, document.title, url);
}
// replace the version in the buildscript
- for (const [modName, modVersions] of version.modVersions) {
- doReplace(modName, modVersions[0]?.name);
+ for (const modName of mods) {
+ doReplace(modName, version.modVersions.get(modName)?.[0]?.name ?? `<${modName.toLocaleUpperCase()}_VERSION>`);
}
}
/**
* @param {Map} projectVersions
+ * @param {string[]} mods
*/
-function updateVersionSelects(projectVersions) {
+function updateVersionSelects(projectVersions, mods) {
const showPreReleases = document.getElementById('include-prereleases')?.checked || false;
/** @type {Map} */
const validVersions = new Map([...projectVersions].filter(([_, { mcVersion }]) => showPreReleases || !mcVersion.isSnapshot));
const selectedVersion = pickDefaultVersion(validVersions);
if (selectedVersion) {
- selectVersion(selectedVersion);
+ selectVersion(selectedVersion, mods);
}
for (const versionSelect of document.getElementsByClassName('mc-version-select')) {
versionSelect.value = selectedVersion?.id;
@@ -103,6 +95,7 @@ function updateVersionSelects(projectVersions) {
* @returns {Promise}
*/
export async function setUpSmartBuildscript(modrinthProjectIds) {
+ const mods = Object.keys(modrinthProjectIds);
const projectVersions = indexVersions(await Promise.all(
Object.entries(modrinthProjectIds).map(
([mod, modrinthProjectId]) =>
@@ -113,10 +106,10 @@ export async function setUpSmartBuildscript(modrinthProjectIds) {
for (const versionSelect of document.getElementsByClassName('mc-version-select')) {
versionSelect.addEventListener('change', () => {
if (projectVersions.has(versionSelect.value)) {
- selectVersion(projectVersions.get(versionSelect.value), true);
+ selectVersion(projectVersions.get(versionSelect.value), mods, true);
}
});
}
- updateVersionSelects(projectVersions);
+ updateVersionSelects(projectVersions, mods);
}
diff --git a/wiki/blabber/index.md b/wiki/blabber/index.md
index 37ae9727..62cdb551 100644
--- a/wiki/blabber/index.md
+++ b/wiki/blabber/index.md
@@ -374,7 +374,7 @@ dependencies {
}
```
{% endcapture %}
-{%- include tabbed_builscript.liquid groovy=groovy kts=kts catalogue=catalogue %}
+{%- include tabbed_builscript.liquid mod1="blabber:2oRMVFgd" mod2="cca:K01OU20C" groovy=groovy kts=kts catalogue=catalogue %}
You can find the current version of Blabber in the [releases](https://github.com/Ladysnake/Blabber/releases) tab of the repository on Github,
diff --git a/wiki/cardinal-components-api/dev-install.md b/wiki/cardinal-components-api/dev-install.md
index b590e143..01b4f5e4 100644
--- a/wiki/cardinal-components-api/dev-install.md
+++ b/wiki/cardinal-components-api/dev-install.md
@@ -11,15 +11,6 @@ mechanism provided by the Fabric toolchain to include Cardinal Components in you
Unless specified otherwise, the following block must be added to your `build.gradle` **after** the relevant `repositories` block:
-
-
-
-
{% capture groovy %}
`gradle.properties`:
```properties
@@ -77,7 +68,7 @@ dependencies {
}
```
{% endcapture %}
-{%- include tabbed_builscript.liquid mod1="cca" groovy=groovy kts=kts catalogue=catalogue %}
+{%- include tabbed_builscript.liquid mod1="cca:K01OU20C" groovy=groovy kts=kts catalogue=catalogue %}
## Ladysnake Reposilite