mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-02-17 07:03:57 +00:00
Integrate gtnh mod (#3727)
Co-authored-by: Geoff Bourne <itzgeoff@gmail.com>
This commit is contained in:
54
docs/types-and-platforms/mod-platforms/gtnh.md
Normal file
54
docs/types-and-platforms/mod-platforms/gtnh.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Auto-setup GTNH server
|
||||
|
||||
[GT New Horizons (GTNH)](https://www.gtnewhorizons.com/) is a Minecraft 1.7.10 modpack maintained and supported by dedicated community members! With over 10 years in development, GTNH offers a carefully balanced and immersive experience to challenge players as they climb through the 15 tiers of technology. The ultimate goal of GTNH is to build the Stargate, an interdimensional teleporter and the symbol for absolute prestige, aptitude, and determination.
|
||||
|
||||
As GTNH is a complex modpack with some specifics it has its own `TYPE` to simplify the deployment and update process. To use it set the environment variable `TYPE` to "GTNH".
|
||||
|
||||
Configuration options with defaults:
|
||||
|
||||
- `GTNH_PACK_VERSION`=latest
|
||||
- `GTNH_DELETE_BACKUPS`=false
|
||||
- `SKIP_GTNH_UPDATE_CHECK`=false
|
||||
|
||||
## Set Modpack version
|
||||
|
||||
As GTNH is a Minecraft 1.7.10 modpack, when using it your minecraft version is set to 1.7.10 by default. The [modpack version](https://www.gtnewhorizons.com/downloads/) can be selected by setting `GTNH_PACK_VERSION` to `latest`, `latest-dev` or any specific version number. `latest` will automatically select the latest full release version available and deploy the server with it (Note: this will also automatically update the server on startup). `latest-dev` does the same but selects the latest version marked as beta or RC (it wont select a full release version even if a newer exist). The third (and recommended) option is setting the server to a specific version like `2.8.1` to manage updates manually.
|
||||
|
||||
> To actively prevent an update from happening you can set the environment variable `SKIP_GTNH_UPDATE_CHECK` to true this will prevent any update check from running, but will also prevent the server install from running, so just set it after the initial setup.
|
||||
|
||||
## Ressource requirements
|
||||
|
||||
**Recommended Minimum:**
|
||||
|
||||
- 2-4 cpu cores
|
||||
- 6GB of RAM +0.5GB per extra player (early game)
|
||||
- 6GB of RAM +1GB per extra player (~UV tier+)
|
||||
- 20GB+ storage. HDD is feasible, SSD is preferred
|
||||
|
||||
For more details regarding the server setup consult the [modpack wiki](https://wiki.gtnewhorizons.com/wiki/Server_Setup).
|
||||
|
||||
## Java Version
|
||||
|
||||
GTNH supports java 8 and 17+ (java 17+ is always recommended for maximum performance). The server will only start when a supported version of itzg/docker-minecraft-server is used.
|
||||
|
||||
For optimal performance choose java25 with GTNH 2.8.0 and later.
|
||||
|
||||
## Config backups
|
||||
|
||||
During version upgrade, the server will replace all config files to make sure all new features are setup as intended. The old config files are stored in a backup folder in the data directory, for you to use as reference for manual reapplication of your changed settings. Set the environment variable `GTNH_DELETE_BACKUPS` to true to delete all backup folders at startup.
|
||||
|
||||
## server.properties defaults
|
||||
|
||||
To deliver the intended GTNH by default, when running a GTNH server, the following options are set in `server.properties`. It is recommended to leave them as is, but if you know what you are doing feel free to play around with them.
|
||||
|
||||
- `LEVEL_TYPE=rwg`
|
||||
- `DIFFICULTY=hard`
|
||||
- `ALLOW_FLIGHT=true`
|
||||
- `ENABLE_COMMAND_BLOCK=true`
|
||||
- `MOTD=Greg Tech New Horizon <current-pack-version>`
|
||||
|
||||
## Java args
|
||||
|
||||
With java 17+ the server starts with `-Dfml.readTimeout=180 @java9args.txt -jar lwjgl3ify-forgePatches.jar`.
|
||||
|
||||
With java 8 the server stars with `-XX:+UseStringDeduplication -XX:+UseCompressedOops -XX:+UseCodeCacheFlushing -Dfml.readTimeout=180 -jar forge-1.7.10-10.13.4.1614-1.7.10-universal.jar`
|
||||
22
examples/gtnh/docker-compose-type-gtnh.yaml
Normal file
22
examples/gtnh/docker-compose-type-gtnh.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
services:
|
||||
mc:
|
||||
# make sure this java version matches with pack java version
|
||||
image: itzg/minecraft-server:java25
|
||||
tty: true
|
||||
stdin_open: true
|
||||
ports:
|
||||
- "25565:25565"
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
TYPE: GTNH
|
||||
GTNH_PACK_VERSION: "2.8.1"
|
||||
# Enable to delete old config backups
|
||||
# GTNH_DELETE_BACKUPS: true
|
||||
# Use to prevent updates
|
||||
# SKIP_GTNH_UPDATE_CHECK: true
|
||||
MEMORY: 6G
|
||||
volumes:
|
||||
# attach a managed volume, change to a relative or absolute host directory if needed
|
||||
- mc-data:/data
|
||||
volumes:
|
||||
mc-data:
|
||||
@@ -190,7 +190,7 @@ if [[ $MODPACK_PLATFORM && $TYPE && $TYPE != VANILLA ]]; then
|
||||
fi
|
||||
|
||||
case "${TYPE^^}" in
|
||||
AUTO_CURSEFORGE|MODRINTH|CURSEFORGE|FTB|FTBA)
|
||||
AUTO_CURSEFORGE|MODRINTH|CURSEFORGE|FTB|FTBA|GTNH)
|
||||
MODPACK_PLATFORM="$TYPE"
|
||||
;;
|
||||
esac
|
||||
@@ -213,6 +213,10 @@ if [[ $MODPACK_PLATFORM ]]; then
|
||||
exec "$(dirname "$0")/start-deployModrinth" "$@"
|
||||
;;
|
||||
|
||||
GTNH)
|
||||
exec "$(dirname "$0")/start-deployGTNH" "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
logError "Invalid MODPACK_PLATFORM: '$MODPACK_PLATFORM'"
|
||||
exit 1
|
||||
|
||||
279
scripts/start-deployGTNH
Normal file
279
scripts/start-deployGTNH
Normal file
@@ -0,0 +1,279 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck source=start-utils
|
||||
. "$(dirname "$0")/start-utils"
|
||||
|
||||
# Define setup functions
|
||||
function getGTNHdownloadPath(){
|
||||
gtnh_download_path=""
|
||||
current_java_version=$(mc-image-helper java-release)
|
||||
|
||||
if ! mapfile -t packs < <(curl -sfL 'http://downloads.gtnewhorizons.com/ServerPacks/?raw'); then
|
||||
logError "Failed to retrieve data from http://downloads.gtnewhorizons.com/ServerPacks/?raw"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Start locating server files..."
|
||||
for pack in "${packs[@]}"; do
|
||||
# Extract the Java version(s) from the pack filename
|
||||
if ! pack_java_version=$(basename "$pack" | grep -Eo 'Java_[0-9]+(-[0-9]+)?' | sed 's/Java_//'); then
|
||||
logWarning "Could not parse java version of $pack"
|
||||
fi
|
||||
|
||||
# Skip the pack if the current Java version is not compatible
|
||||
if [[ "$pack_java_version" == *-* ]]; then
|
||||
# Handle range of Java versions (e.g., "17-21")
|
||||
java_min_version=$(echo "$pack_java_version" | cut -d'-' -f1)
|
||||
java_max_version=$(echo "$pack_java_version" | cut -d'-' -f2)
|
||||
if (( current_java_version < java_min_version || current_java_version > java_max_version )); then
|
||||
debug "Skipping $pack due to incompatible Java version: $current_java_version not in range $java_min_version-$java_max_version"
|
||||
continue
|
||||
fi
|
||||
else
|
||||
# Handle single Java version (e.g., "8")
|
||||
if (( current_java_version != pack_java_version )); then
|
||||
debug "Skipping $pack due to incompatible Java version: $current_java_version != $pack_java_version"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# Extract version numbers and release type (beta or RC) from the file names
|
||||
|
||||
if ! pack_version=$(basename "$pack" | grep -Eo '[0-9]+(\.[0-9]+)+'); then
|
||||
logWarning "Could not parse version of $pack"
|
||||
fi
|
||||
if ! pack_release_type=$(basename "$pack" | grep -Eo '(beta|RC)(-[0-9]+)?' || echo ""); then
|
||||
logWarning "Could not parse release type of $pack"
|
||||
fi
|
||||
if ! current_version=$(basename "$gtnh_download_path" | grep -Eo '[0-9]+(\.[0-9]+)+'); then
|
||||
debug "Could not parse version of selected download path. String might be empty."
|
||||
fi
|
||||
if ! current_release_type=$(basename "$gtnh_download_path" | grep -Eo '(beta|RC)(-[0-9]+)?' || echo ""); then
|
||||
debug "Could not parse release type of selected download path. String might be empty."
|
||||
fi
|
||||
# Check if the pack matches the desired type based on GTNH_PACK_VERSION:
|
||||
# - If GTNH_PACK_VERSION is "latest-dev", only consider beta packs (path contains "/betas/").
|
||||
# - If GTNH_PACK_VERSION is "latest", only consider non-beta packs (path does not contain "/betas/").
|
||||
if [[ ($pack == *"/betas/"* && $GTNH_PACK_VERSION == "latest-dev") || ($pack != *"/betas/"* && $GTNH_PACK_VERSION == "latest") ]]; then
|
||||
# Compare versions and update gtnh_download_path if pack is newer
|
||||
# Check if the current version is unset or if the pack version is newer than the current version.
|
||||
# This comparison uses version sorting to determine the latest version.
|
||||
if [[ -z "$current_version" || "$(printf '%s\n' "$pack_version" "$current_version" | sort -V | tail -n 1)" == "$pack_version" ]]; then
|
||||
|
||||
# If the pack version is the same as the current version, prioritize based on release type.
|
||||
# Full versions are preferred over RC (Release Candidate), and RC is preferred over beta.
|
||||
# Within the same release type, higher numbered versions are preferred.
|
||||
if [[ "$pack_version" == "$current_version" ]]; then
|
||||
if [[ -z "$pack_release_type" || ("$pack_release_type" == "RC" && "$current_release_type" == "beta") ||
|
||||
("$pack_release_type" == "$current_release_type" && "$(printf '%s\n' "$pack_release_type" "$current_release_type" | sort -V | tail -n 1)" == "$pack_release_type") ]]; then
|
||||
debug "$current_version-$current_release_type is older than $pack_version-$pack_release_type! Update latest version to: $pack_version-$pack_release_type"
|
||||
gtnh_download_path="$pack"
|
||||
fi
|
||||
else
|
||||
# If the pack version is newer than the current version, set it as the download path.
|
||||
debug "$current_version is older than $pack_version! Update latest version to: $pack_version"
|
||||
gtnh_download_path="$pack"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ "$pack_version" == "$GTNH_PACK_VERSION" || "$pack_version-$pack_release_type" == "$GTNH_PACK_VERSION" ]]; then
|
||||
log "Found exact match $pack_version = $GTNH_PACK_VERSION! Select $pack_version for download."
|
||||
gtnh_download_path="$pack"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function deleteGTNHbackup(){
|
||||
log "Start deleting all config backups"
|
||||
if ! find . -maxdepth 1 -type d -name 'gtnh-upgrade-*' -exec rm -rf {} + ; then
|
||||
logWarning "Can not delete config backup!"
|
||||
fi
|
||||
}
|
||||
|
||||
function updateGTNH(){
|
||||
# Get the current date and time
|
||||
current_datetime=$(date +%Y-%m-%dT%H:%M)
|
||||
|
||||
# Define folders and files to update
|
||||
folders_to_update=("libraries" "mods" "resources" "scripts")
|
||||
files_to_update=("lwjgl3ify-forgePatches.jar" "java9args.txt" "startserver-java9.bat" "startserver-java9.sh" "forge-1.7.10-10.13.4.1614-1.7.10-universal.jar" "startserver.bat" "startserver.sh" "server-icon.png")
|
||||
config_folder="config"
|
||||
backup_folder="/data/gtnh-upgrade-${current_version}${current_release_type:+-$current_release_type}-$current_datetime"
|
||||
journey_map_folder="JourneyMapServer"
|
||||
|
||||
# Delete specified folders if they exist
|
||||
for folder in "${folders_to_update[@]}"; do
|
||||
folder_path="/data/$folder"
|
||||
if [[ -d "$folder_path" ]]; then
|
||||
log "Deleting folder: $folder_path"
|
||||
rm -rf "$folder_path"
|
||||
fi
|
||||
done
|
||||
|
||||
# Delete specific files if they exist
|
||||
for file in "${files_to_update[@]}"; do
|
||||
file_path="/data/$file"
|
||||
if [[ -f "$file_path" ]]; then
|
||||
log "Deleting file: $file_path"
|
||||
rm -f "$file_path"
|
||||
fi
|
||||
done
|
||||
|
||||
# Backup the config folder
|
||||
if [[ -d "/data/$config_folder" ]]; then
|
||||
log "Creating backup of /data/$config_folder at $backup_folder"
|
||||
cp -r "/data/$config_folder" "$backup_folder"
|
||||
log "Deleting original /data/$config_folder"
|
||||
rm -rf "/data/$config_folder"
|
||||
fi
|
||||
|
||||
# Updating the required folders in data directory
|
||||
for folder in "${folders_to_update[@]}" "$config_folder"; do
|
||||
if [[ -d "$base_dir/$folder" ]]; then
|
||||
log "Copying $folder to /data"
|
||||
cp -r "$base_dir/$folder" "/data/"
|
||||
else
|
||||
logWarning "Folder $folder not found in the unzipped data!"
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy specific files to the /data directory
|
||||
for file in "${files_to_update[@]}"; do
|
||||
if [[ -f "$base_dir/$file" ]]; then
|
||||
log "Copying $file to /data"
|
||||
cp "$base_dir/$file" "/data/"
|
||||
else
|
||||
logWarning "File $file not found in the unzipped data!"
|
||||
fi
|
||||
done
|
||||
|
||||
# Ensure the config folder exists
|
||||
if [[ ! -d "$config_folder" ]]; then
|
||||
log "$config_folder does not exist. Creating it now."
|
||||
mkdir -p "$config_folder"
|
||||
fi
|
||||
|
||||
# Restore JourneyMapServer folder from backup
|
||||
if [[ -d "$backup_folder/$journey_map_folder" ]]; then
|
||||
log "Restoring $journey_map_folder to $config_folder"
|
||||
cp -r "$backup_folder/$journey_map_folder" "$config_folder/"
|
||||
else
|
||||
logWarning "$journey_map_folder not found in backup!"
|
||||
fi
|
||||
|
||||
# Copy the changelog file to /data
|
||||
gtnh_changelog_file=$(mc-image-helper find --max-depth=1 --type=file --name=changelog*.md "$base_dir")
|
||||
if [[ -n "$gtnh_changelog_file" ]]; then
|
||||
log "Copying changelog file to /data"
|
||||
cp -f "$gtnh_changelog_file" /data/
|
||||
fi
|
||||
}
|
||||
|
||||
function handleGTNH() {
|
||||
|
||||
: "${GTNH_PACK_VERSION:=latest}"
|
||||
: "${GTNH_DELETE_BACKUPS:=false}"
|
||||
: "${SKIP_GTNH_UPDATE_CHECK:=false}"
|
||||
debug "GTNH VAR CHECK: GTNH_DELETE_BACKUPS=$GTNH_DELETE_BACKUPS, GTNH_PACK_VERSION=$GTNH_PACK_VERSION, TYPE=$TYPE, SKIP_GTNH_UPDATE_CHECK=$SKIP_GTNH_UPDATE_CHECK"
|
||||
|
||||
if isTrue "$GTNH_DELETE_BACKUPS"; then
|
||||
deleteGTNHbackup
|
||||
fi
|
||||
|
||||
if [[ -n $GTNH_PACK_VERSION ]] && isFalse "$SKIP_GTNH_UPDATE_CHECK" ; then
|
||||
|
||||
getGTNHdownloadPath
|
||||
|
||||
if [[ -z $gtnh_download_path ]]; then
|
||||
logError "Server files not found for GTNH_PACK_VERSION=$GTNH_PACK_VERSION! Download not possible!"
|
||||
exit 1
|
||||
fi
|
||||
log "Server files located! Will proceed update $gtnh_download_path."
|
||||
|
||||
# Decide if update or install is needed or not.
|
||||
if [[ ! -f /data/.gtnh-version || "$(basename "$gtnh_download_path")" != "$(cat /data/.gtnh-version)" ]]; then
|
||||
log "Update/Install required: /data/.gtnh-version is missing or does not match the selected version $(basename "$gtnh_download_path")."
|
||||
|
||||
mkdir -p /data/packs
|
||||
log "Downloading $gtnh_download_path."
|
||||
if ! gtnh_download=$(mc-image-helper get -o /data/packs --output-filename --skip-up-to-date "$gtnh_download_path"); then
|
||||
logError "Failed to download $gtnh_download_path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Unpacking Server files into temporary directory
|
||||
log "Unpacking Server Files..."
|
||||
original_base_dir=/data/.tmp/gtnh_base
|
||||
base_dir=$original_base_dir
|
||||
rm -rf "${base_dir}"
|
||||
mkdir -p "${base_dir}"
|
||||
extract "${gtnh_download}" "${base_dir}"
|
||||
trap 'rm -rf /data/.tmp' EXIT
|
||||
# Removing downloaded zip
|
||||
rm -f "$gtnh_download"
|
||||
|
||||
# Remove any eula file since container manages it
|
||||
rm -f "${base_dir}/eula.txt"
|
||||
|
||||
# recalculate the actual base directory of content
|
||||
if ! base_dir=$(mc-image-helper find \
|
||||
--max-depth=3 --type=directory --name=mods,config \
|
||||
--only-shallowest --fail-no-matches --format '%h' \
|
||||
"$base_dir"); then
|
||||
logError "Unable to find content base of downloaded Server Files"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Split installation from update path. Check for version file.
|
||||
if [[ -f /data/.gtnh-version ]]; then
|
||||
log ".gtnh-version file detected! Assuming old version already exists. Proceed updating existing server..."
|
||||
updateGTNH
|
||||
else
|
||||
log "No .gtnh-version file detected! Assuming no old server exists. Proceed installing new server..."
|
||||
cp -R -f "${base_dir}"/* /data
|
||||
fi
|
||||
# Update .gtnh-version
|
||||
basename "$gtnh_download_path" > /data/.gtnh-version
|
||||
# Cleaning up
|
||||
rm -rf "$original_base_dir"
|
||||
|
||||
else
|
||||
log "No update required: /data/.gtnh-version matches the selected version $(basename "$gtnh_download_path")."
|
||||
fi
|
||||
else
|
||||
log "SKIP_GTNH_UPDATE_CHECK=$SKIP_GTNH_UPDATE_CHECK ... Skipping GTNH Update/Install"
|
||||
fi
|
||||
}
|
||||
|
||||
# Set server.properties defaults suitable for gtnh servers
|
||||
log "Applying GTNH optimized server defaults"
|
||||
export ALLOW_FLIGHT="${ALLOW_FLIGHT:=true}"
|
||||
export LEVEL_TYPE="${LEVEL_TYPE:=rwg}"
|
||||
export DIFFICULTY="${DIFFICULTY:=3}"
|
||||
export ENABLE_COMMAND_BLOCK="${ENABLE_COMMAND_BLOCK:=true}"
|
||||
export MOTD="${MOTD:="Greg Tech New Horizon $GTNH_PACK_VERSION"}"
|
||||
debug "Set MOTD=$MOTD, ENABLE_COMMAND_BLOCK=$ENABLE_COMMAND_BLOCK, DIFFICULTY=$DIFFICULTY, LEVEL_TYPE=$LEVEL_TYPE, ALLOW_FLIGHT=$ALLOW_FLIGHT"
|
||||
|
||||
isDebugging && set -x
|
||||
|
||||
ensureRemoveAllModsOff "MODPACK_PLATFORM=GTNH"
|
||||
|
||||
java_version=$(mc-image-helper java-release)
|
||||
if (( java_version == 8 )); then
|
||||
export SERVER=/data/forge-1.7.10-10.13.4.1614-1.7.10-universal.jar
|
||||
elif (( java_version >= 17 )); then
|
||||
export SERVER=/data/lwjgl3ify-forgePatches.jar
|
||||
else
|
||||
logError "Greg Tech New Horizons only supports the following Java versions: 8, 17 or later"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "TYPE=GTNH, setting Minecraft version to 1.7.10"
|
||||
export VERSION=1.7.10
|
||||
|
||||
# Start setup gtnh server files
|
||||
handleGTNH
|
||||
|
||||
exec "$(dirname "$0")/start-setupWorld" "$@"
|
||||
@@ -349,6 +349,23 @@ if isTrue "${USE_SIMD_FLAGS}"; then
|
||||
"
|
||||
fi
|
||||
|
||||
# Handle GTNH args
|
||||
if isType "GTNH"; then
|
||||
expandedDOpts="${expandedDOpts} -Dfml.readTimeout=180"
|
||||
java_major_version=$(mc-image-helper java-release)
|
||||
if (( java_major_version == 8 )); then
|
||||
debug "Setting GTNH java8 args."
|
||||
JVM_XX_OPTS="${JVM_XX_OPTS}
|
||||
-XX:+UseStringDeduplication
|
||||
-XX:+UseCompressedOops
|
||||
-XX:+UseCodeCacheFlushing
|
||||
"
|
||||
elif (( java_major_version >= 17 )); then
|
||||
debug "Setting GTNH java17+ args."
|
||||
expandedDOpts="${expandedDOpts} @java9args.txt"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${INIT_MEMORY} || ${MAX_MEMORY} ]]; then
|
||||
log "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
|
||||
if [[ ${INIT_MEMORY} ]]; then
|
||||
|
||||
Reference in New Issue
Block a user