Skip to content
Merged
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
4 changes: 2 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ In the cloned copy of [`mc-image-helper`](https://github.com/itzg/mc-image-helpe
Assuming [http-server](https://www.npmjs.com/package/http-server) is installed globally, start a static web server using:

```shell
http-server ./build/distributions -p 0
http-server ./build/distributions -p 8080
```

Note the port that was selected by http-server and pass the build arguments, such as:
Expand All @@ -88,7 +88,7 @@ Note the port that was selected by http-server and pass the build arguments, suc
--build-arg MC_HELPER_BASE_URL=http://host.docker.internal:8080
```

Now the image can be built like normal and it will install mc-image-helper from the locally built copy.
Now the image can be built like normal, and it will install mc-image-helper from the locally built copy.

## Generating release notes

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.18.3
ARG MC_HELPER_VERSION=1.19.0
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 - \
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -876,28 +876,30 @@ Datapacks will be placed in `/data/$LEVEL/datapacks`

### VanillaTweaks

VanillaTweaks datapacks can be installed with a share code from the website UI **OR** a json file to specify packs to download and install.
[VanillaTweaks](https://vanillatweaks.net/) datapacks, crafting tweaks, and resource packs can be installed with a share code from the website **OR** a json file to specify packs to download and install. Datapacks and crafting tweaks will be installed into the current world directory specified by `$LEVEL`. As new versions of the packs are retrieved the previous versions will automatically be cleaned up.

Datapacks will be placed in `/data/$LEVEL/datapacks`
Resourcepacks will be placed in `/data/resourcepacks`
The share code is the part following the hash sign, as shown here:

```
https://vanillatweaks.net/share/#MGr52E
------
|
+- share code MGr52E
```

Accepted Parameters:

- `VANILLATWEAKS_FILE`
- `VANILLATWEAKS_SHARECODE`
- `REMOVE_OLD_VANILLATWEAKS`
- `REMOVE_OLD_VANILLATWEAKS_DEPTH`
- `REMOVE_OLD_VANILLATWEAKS_INCLUDE`
- `REMOVE_OLD_VANILLATWEAKS_EXCLUDE`
- `VANILLATWEAKS_FILE`: comma separated list of JSON VanillaTweak pack files accessible within the container
- `VANILLATWEAKS_SHARECODE`: comma separated list of share codes

Example of expected Vanillatweaks sharecode:
Example of expected VanillaTweaks share codes:
**Note**: ResourcePacks, DataPacks, and CraftingTweaks all have separate sharecodes

```yaml
VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
```

Example of expected Vanillatweaks file format:
Example of expected VanillaTweaks files:

```yaml
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
Expand Down Expand Up @@ -925,8 +927,7 @@ Resourcepacks Json:
"version": "1.18",
"packs": {
"aesthetic": ["CherryPicking", "BlackNetherBricks", "AlternateBlockDestruction"]
},
"result": "ok"
}
}
```

Expand All @@ -941,8 +942,7 @@ CraftingTweaks Json:
"double slabs",
"back to blocks"
]
},
"result": "ok"
}
}
```

Expand Down
119 changes: 6 additions & 113 deletions scripts/start-setupVanillaTweaks
Original file line number Diff line number Diff line change
Expand Up @@ -2,125 +2,18 @@

set -e -o pipefail

: "${REMOVE_OLD_VANILLATWEAKS:=false}"
: "${VANILLATWEAKS_FILE:=}"
: "${VANILLATWEAKS_SHARECODE:=}"
: "${REMOVE_OLD_VANILLATWEAKS_DEPTH:=1} "
: "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:=*.zip}"

# shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils"
isDebugging && set -x

VT_VERSION=""
DATAPACKS_DIR="/data/${LEVEL:-world}/datapacks"
RESOURCEPACKS_DIR="/data/resourcepacks"

# Remove old VANILLATWEAKS
if isTrue "${REMOVE_OLD_VANILLATWEAKS}"; then
# NOTE: datapacks include crafting tweaks.
if [ -d "$DATAPACKS_DIR" ]; then
find "$DATAPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete
fi
if [ -d "$RESOURCEPACKS_DIR" ]; then
find "$RESOURCEPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete
fi
fi

# Gets the download url and downloads the actual files.
getUrlAndDownload(){
VT_FILE=$1
URL_SUFFIX=$2
OUTPUT_FILE=$3
PACKS=$(jq -jc '.packs // empty' $VT_FILE)
if [ ! "$PACKS" ]; then
log "ERROR: unable to retrieve ${URL_SUFFIX} from ${VT_FILE}"
exit 2
fi

ZIPDATA_URL="https://vanillatweaks.net/assets/server/zip${URL_SUFFIX}.php"
DOWNLOAD_URL=$(curl -X POST -F "packs=${PACKS}" -F "version=${VT_VERSION}" $ZIPDATA_URL | jq -r '.link // empty')
if [ ! "$DOWNLOAD_URL" ]; then
log "ERROR: unable to retrieve ${URL_SUFFIX} packs from vanillatweaks.net!"
exit 2
fi

if ! get -o $OUTPUT_FILE "https://vanillatweaks.net${DOWNLOAD_URL}"; then
log "ERROR: failed to download ${URL_SUFFIX} from ${DOWNLOAD_URL}"
exit 2
fi
}

# Datapacks Handler
downloadDatapacks(){
VT_FILE=$1
URL_SUFFIX="datapacks"
OUTPUT_FILE="/tmp/vanillatweaks.zip"
getUrlAndDownload $VT_FILE $URL_SUFFIX $OUTPUT_FILE
mkdir -p "$DATAPACKS_DIR"
if ! unzip -o -d "$DATAPACKS_DIR" $OUTPUT_FILE; then
log "ERROR: failed to unzip the datapacks ${DATAPACKS} from ${OUTPUT_FILE}"
fi
rm -f $OUTPUT_FILE
}

# Crafting Tweaks Handler
downloadCraftingtweaks(){
VT_FILE=$1
mkdir -p "$DATAPACKS_DIR"
getUrlAndDownload $VT_FILE "craftingtweaks" "${DATAPACKS_DIR}/craftingtweaks.zip"
}

# Resourcepacks Handler
downloadResourcepacks(){
VT_FILE=$1
mkdir -p "$RESOURCEPACKS_DIR"
getUrlAndDownload $VT_FILE "resourcepacks" "${RESOURCEPACKS_DIR}/resourcepacks.zip"
}

# Example: VANILLATWEAKS_SHARECODE=MGr52E
# Code generated from the UI website, typically a alphanumeric 6 digit code.
if [[ "$VANILLATWEAKS_SHARECODE" ]]; then
VANILLATWEAKS_FILE=()
for SHARECODE in ${VANILLATWEAKS_SHARECODE//,/ }; do
TMP_FILE="/tmp/${SHARECODE}.json"
SHARECODE_LOOKUP_URL="https://vanillatweaks.net/assets/server/sharecode.php?code=${SHARECODE}"
if ! get -o "$TMP_FILE" "$SHARECODE_LOOKUP_URL"; then
log "ERROR: Unable to use ${SHARECODE} share code provided to retrieve vanillatweaks file"
exit 2
fi
VANILLATWEAKS_FILE+="${TMP_FILE},"
done
fi

# Use vanillatweaks file to specify VT and datapacks and crafting tweaks
if [[ "$VANILLATWEAKS_FILE" ]]; then
for VT_FILE in ${VANILLATWEAKS_FILE//,/ }; do
if [ ! -f "$VT_FILE" ]; then
log "ERROR: given VANILLATWEAKS_FILE file does not exist"
exit 2
fi

VT_VERSION=$(jq -jc '.version // empty' $VT_FILE)
if [ ! "$VT_VERSION" ]; then
log "ERROR: unable to retrieve version from $VT_FILE"
exit 2
fi

TYPE=$(jq -jc '.type // empty' $VT_FILE)
if [[ "$TYPE" = "datapacks" ]]; then
downloadDatapacks $VT_FILE
elif [[ "$TYPE" = "craftingtweaks" ]]; then
downloadCraftingtweaks $VT_FILE
elif [[ "$TYPE" = "resourcepacks" ]]; then
downloadResourcepacks $VT_FILE
fi

# cleans up temp vanilla tweaks file download to get stored packs
if [[ "$VANILLATWEAKS_SHARECODE" ]]; then
rm -f $VT_FILE
fi
done
if [[ ${VANILLATWEAKS_FILE} || ${VANILLATWEAKS_SHARECODE} ]]; then
mc-image-helper vanillatweaks \
--output-directory="/data" \
--world-subdir="${LEVEL:-world}" \
--share-codes="$VANILLATWEAKS_SHARECODE" \
--pack-files="$VANILLATWEAKS_FILE"
fi

exec "${SCRIPTS:-/}start-setupDatapack" "$@"
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
version: "3"

services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
REMOVE_OLD_VANILLATWEAKS: "FALSE"
volumes:
- ./data:/data
- ./vt-datapacks.json:/config/vt-datapacks.json:ro
- ./vt-craftingtweaks.json:/config/vt-craftingtweaks.json:ro
- ./vt-resourcepacks.json:/config/vt-resourcepacks.json:ro
version: "3"

services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
CUSTOM_SERVER: /servers/fake.jar
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
REMOVE_OLD_VANILLATWEAKS: "FALSE"
volumes:
- ./data:/data
- ./vt-datapacks.json:/config/vt-datapacks.json:ro
- ./vt-craftingtweaks.json:/config/vt-craftingtweaks.json:ro
- ./vt-resourcepacks.json:/config/vt-resourcepacks.json:ro
- ./fake.jar:/servers/fake.jar
Empty file.
4 changes: 2 additions & 2 deletions tests/setuponlytests/vanillatweaks_file/verify.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*"
mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*"
mc-image-helper assert fileExists "/data/world/datapacks/VanillaTweaks_*"
mc-image-helper assert fileExists "/data/resourcepacks/VanillaTweaks_*"
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ services:
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
CUSTOM_SERVER: /servers/fake.jar
VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
REMOVE_OLD_VANILLATWEAKS: "FALSE"
volumes:
- ./data:/data
- ./fake.jar:/servers/fake.jar
Empty file.
4 changes: 2 additions & 2 deletions tests/setuponlytests/vanillatweaks_sharecode/verify.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*"
mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*"
mc-image-helper assert fileExists "/data/world/datapacks/VanillaTweaks_488158f.zip"
mc-image-helper assert fileExists "/data/resourcepacks/VanillaTweaks_d1d810f.zip"