Skip to content

Commit

Permalink
read versions from gradle properties
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Mar 31, 2024
1 parent 49fefb5 commit 7055bcb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
fabric_loader_version=0.15.7
fabric_api_version=0.96.4+1.20.4
headlessmc_version=1.9.1
baritone_version=1.10.2
49 changes: 34 additions & 15 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@ set -o errexit
set -o nounset
set -o pipefail

headlessmc() {
docker run --rm \
hmc() {
docker run -it --rm \
-p "127.0.0.1:8080:8080" \
-v "${PWD}/mc:/work/.minecraft" \
-v "${PWD}/hmc:/work/HeadlessMC" \
"n0thub/headlessmc:1.9.1" \
"n0thub/headlessmc:${hmc_version}" \
"${@}"
}

# workdir is repository root
cd "$(dirname "$(realpath "$0")")/.."
prop() {
cat gradle.properties \
| grep -E -m 1 "${1}"'\s*=' \
| sed -E 's/^\w+\s*=\s*//'
}

./gradlew --console plain --info --full-stacktrace clean check build
hmc_version="$(prop 'headlessmc_version')"
mc_version="$(prop 'minecraft_version')"
fabric_version="$(prop 'fabric_loader_version')"

# workdir
cd "$(dirname "$(realpath "$0")")/.."
mkdir -p run
cd run

Expand All @@ -31,17 +38,17 @@ if test ! -f "hmc/auth/.account.json"; then
password="${2}"
fi
# TODO: stop passing sensitive data as command arguments
headlessmc login "${username}" "${password}"
hmc login "${username}" "${password}"
fi

# download mc
if test ! -e "mc/versions/1.20.4"; then
headlessmc download "1.20.4"
if test ! -e "mc/versions/${mc_version}"; then
hmc download "${mc_version}"
fi

# download fabric
if test ! -e "mc/versions/fabric-loader-0.15.7-1.20.4"; then
headlessmc fabric "1.20.4"
if test ! -e "mc/versions/fabric-loader-${fabric_version}-${mc_version}"; then
hmc fabric "${mc_version}"
fi

# download mods
Expand All @@ -58,9 +65,21 @@ for mod in $(echo "$mods" | jq -c '.[]'); do
fi
done

# install our mod
cp ../build/libs/headlessbot.jar mc/mods/
(
cd ..

# build our mod
./gradlew --console plain --info --full-stacktrace clean check build

# install our mod
cp ./build/libs/headlessbot.jar run/mc/mods/
)

# find fabric profile
profile="$(hmc versions | grep -E '\s+fabric-loader-' | awk 'NR==1{print $2}')"

# launch bot
hmc launch "${profile}"

# launch bot + monitoring
cd ..
docker compose up --abort-on-container-exit --force-recreate -V
#docker compose up --abort-on-container-exit --force-recreate -V

0 comments on commit 7055bcb

Please sign in to comment.