Added support for downloading mods from Modrinth (#1577)

This commit is contained in:
Geoff Bourne 2022-06-27 09:08:21 -05:00 committed by GitHub
parent 8d7a5275a8
commit 7001f2bcba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 143 additions and 70 deletions

View File

@ -46,7 +46,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
ARG MC_HELPER_VERSION=1.17.0
ARG MC_HELPER_VERSION=1.18.3
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
| tar -C /usr/share -zxf - \

View File

@ -684,6 +684,20 @@ For example, the following will auto-download the [EssentialsX](https://www.spig
-e SPIGET_RESOURCES=9089,34315
### Auto-download mods from Modrinth
[Modrinth](https://modrinth.com/) is an open source modding platform with a clean, easy to use website for finding [Fabric and Forge mods](https://modrinth.com/mods). At startup, the container will automatically locate and download the newest versions of mod files that correspond to the `TYPE` and `VERSION` in use. Older file versions downloaded previously will automatically be cleaned up.
- **MODRINTH_PROJECTS** : comma separated list of project slugs (short name) or IDs. The project ID can be located in the "Technical information" section. The slug is the part of the page URL that follows `/mod/`:
```
https://modrinth.com/mod/fabric-api
----------
|
+-- project slug
```
- **MODRINTH_DOWNLOAD_OPTIONAL_DEPENDENCIES**=true : required dependencies of the project will _always_ be downloaded and optional dependencies can also be downloaded by setting this to `true`
- **MODRINTH_ALLOWED_VERSION_TYPE**=release : the version type is used to determine the newest version to use from each project. The allowed values are `release`, `beta`, `alpha`.
### Downloadable mod/plugin pack for Forge, Fabric, and Bukkit-like Servers
Like the `WORLD` option above, you can specify the URL or path of a "mod pack"
@ -899,7 +913,7 @@ Datapacks Json:
"packs": {
"survival": [
"graves",
"multiplayer sleep",
"multiplayer sleep"
],
"items": ["armored elytra"]
}

View File

@ -0,0 +1,18 @@
version: "3.8"
services:
mc:
image: itzg/minecraft-server
tty: true
stdin_open: true
ports:
- "25565:25565"
environment:
EULA: "TRUE"
TYPE: FABRIC
MODRINTH_PROJECTS: fallingtree
volumes:
- data:/data
volumes:
data: {}

View File

@ -195,11 +195,12 @@ case "X$EFFECTIVE_MANIFEST_FILE" in
esac
fi
: "${GENERIC_PACKS:=${GENERIC_PACK}}"
: "${GENERIC_PACKS_PREFIX:=}"
: "${GENERIC_PACKS_SUFFIX:=}"
function genericPacks() {
: "${GENERIC_PACKS:=${GENERIC_PACK}}"
: "${GENERIC_PACKS_PREFIX:=}"
: "${GENERIC_PACKS_SUFFIX:=}"
if [[ "${GENERIC_PACKS}" ]]; then
if [[ "${GENERIC_PACKS}" ]]; then
IFS=',' read -ra packs <<< "${GENERIC_PACKS}"
packFiles=()
@ -264,6 +265,32 @@ if [[ "${GENERIC_PACKS}" ]]; then
sha1sum "${packFiles[@]}" > "${sum_file}"
isDebugging && cat "$sum_file"
fi
fi
fi
}
function modrinthProjects() {
: "${MODRINTH_PROJECTS:=}"
: "${MODRINTH_DOWNLOAD_OPTIONAL_DEPENDENCIES:=true}"
: "${MODRINTH_ALLOWED_VERSION_TYPE:=release}"
if [[ $MODRINTH_PROJECTS ]] && isFamily HYBRID FABRIC; then
if [[ ${FAMILY^^} = HYBRID ]]; then
loader=forge
else
loader="${FAMILY,,}"
fi
mc-image-helper modrinth \
--output-directory=/data \
--projects="${MODRINTH_PROJECTS}" \
--game-version="${VANILLA_VERSION}" \
--loader="$loader" \
--download-optional-dependencies="$MODRINTH_DOWNLOAD_OPTIONAL_DEPENDENCIES" \
--allowed-version-type="$MODRINTH_ALLOWED_VERSION_TYPE"
fi
}
genericPacks
modrinthProjects
exec "${SCRIPTS:-/}start-setupModconfig" "$@"

View File

@ -212,11 +212,7 @@ function removeOldMods {
}
function get() {
local flags=()
if isTrue "${DEBUG_GET:-false}"; then
flags+=("--debug")
fi
mc-image-helper "${flags[@]}" get "$@"
mc-image-helper get "$@"
}
function get_silent() {

View File

@ -9,6 +9,7 @@ services:
GENERIC_PACKS: testing
GENERIC_PACKS_PREFIX: /packs/
GENERIC_PACKS_SUFFIX: .zip
DEBUG: "true"
volumes:
- ./packs:/packs
- ./data:/data

View File

@ -18,6 +18,7 @@ services:
TYPE: CUSTOM
CUSTOM_SERVER: /servers/fake.jar
VERSION: 1.18.1
DEBUG: "true"
volumes:
- ./packs:/packs
- ./data:/data

View File

@ -0,0 +1,15 @@
version: "3"
services:
mc:
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "true"
SETUP_ONLY: "true"
TYPE: FABRIC
FABRIC_LAUNCHER: /servers/fake.jar
CUSTOM_SERVER: /servers/fake.jar
MODRINTH_PROJECTS: fabric-api,cloth-config
volumes:
- ./data:/data
- ./fake.jar:/servers/fake.jar

View File

View File

@ -0,0 +1 @@
mc-image-helper assert fileExists "mods/cloth-config-*.jar" "mods/fabric-api-*.jar"