blob: 596990bdc48d723b69da4405f5e5c467759d182d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/usr/bin/env sh
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')
# Only accepts 1 argument: the Minecraft profile to launch
INAME=
if [ -z "${1}" ]; then
echo "usage: ${0} <version>"
echo 'note: Make sure you downloaded a version first with get_version.sh'
exit 1
else
INAME="${1}"
fi
# Setup and read configurations
JAVA=java
MCUSER=Player
JARGS='-Xms512M -Xmx1024M'
VERSION=
BLACKLISTED_LIBRARIES=
BLACKLISTED_NATIVES=
ADDITIONAL_LIBRARIES=
XARGS=
if [ -f 'user.local' ]; then
. "./user.local"
else
echo "JAVA=${JAVA}" > user.local
echo "MCUSER=${MCUSER}" >> user.local
echo "JARGS='${JARGS}'" >> user.local
fi
if [ -f "profiles.local/${INAME}" ]; then
. "profiles.local/${INAME}"
elif [ -f "profiles/${INAME}" ]; then
. "profiles/${INAME}"
else
echo "ERROR: Specified profile does not exist."
exit 1
fi
if [ ! -f "manifests/${VERSION}.json" ]; then
echo "Invalid version detected. Either it is mistyped, or you have not downloaded it yet."
exit 1
fi
MINECRAFT_JAR=${MINECRAFT_JAR:=libraries/com/mojang/minecraft/${VERSION}/minecraft-${VERSION}-client.jar}
VERSION_MANIFEST=$(cat "manifests/${VERSION}.json")
# Some libraries included in the manifests are known to cause issues, so we blacklist them here
# 1.12 and earlier, natives and regular libraries are contained in different elements. For 1.13 and later, an element may contain both.
CLASSPATH=
for I in $(echo "${VERSION_MANIFEST}" | jq -c .libraries.[]); do
if [[ $(echo "${I}" | jq .downloads.artifact) != 'null' ]]; then
for J in ${BLACKLISTED_LIBRARIES}; do
if [ ${J} == $(basename $(echo ${I} | jq -r .downloads.artifact.path)) ]; then
SKIP=1
fi
done
if [[ ${SKIP} -eq 1 ]]; then
SKIP=
continue
fi
JAR=$(echo ${I} | jq -r .downloads.artifact.path)
if [ "${JAR}" != 'null' ]; then
CLASSPATH="${PWD}/libraries/${JAR}:${CLASSPATH}"
fi
fi
if [[ $(echo "${I}" | jq .natives) != 'null' ]]; then
for J in ${BLACKLISTED_NATIVES}; do
if [ ${J} == $(basename $(echo ${I} | jq ".downloads.classifiers.\"natives-${PLATFORM}\".path")) ]; then
SKIP=1
fi
done
if [[ ${SKIP} -eq 1 ]]; then
SKIP=
continue
fi
JAR=$(echo ${I} | jq -r ".downloads.classifiers.\"natives-${PLATFORM}\".path")
if [ "${JAR}" != 'null' ]; then
CLASSPATH="${PWD}/libraries/${JAR}:${CLASSPATH}"
fi
fi
done
for I in ${ADDITIONAL_LIBRARIES}; do
CLASSPATH="${CLASSPATH}:${PWD}/${I}"
done
CLASSPATH="${CLASSPATH}:${PWD}/${MINECRAFT_JAR}"
if [[ $(echo "${VERSION_MANIFEST}" | jq -r .minecraftArguments) != 'null' ]]; then
ARGUMENT_LIST=$(echo ${VERSION_MANIFEST} | jq -r .minecraftArguments)
else
for I in $(echo ${VERSION_MANIFEST} | jq -r '.arguments.game[] | select(type=="string")'); do
ARGUMENT_LIST="${ARGUMENT_LIST} ${I}"
done
fi
ARGUMENTS="$(echo ${ARGUMENT_LIST} | sed -e "s/\${auth_player_name}/${MCUSER}/" -e "s/\${version_name}/${VERSION}/" -e "s@\${game_directory}@\"${PWD}/instances/${INAME}\"@" -e "s@\${assets_root}@${PWD}/assets@" -e "s/\${assets_index_name}/$(echo ${VERSION_MANIFEST} | jq -r .assetIndex.id)/" -e 's/${auth_uuid}/00000000-0000-0000-0000-000000000000/' -e 's/${auth_access_token}/0/' -e 's/${user_type}/mojang/' -e "s/\${version_type}/$(echo ${VERSION_MANIFEST} | jq -r .type)/" -e 's/${user_properties}/{}/' -e "s@\${game_assets}@${PWD}/assets/virtual/legacy@" -e 's/${auth_session}/0/')"
MAINCLASS=${MAINCLASS:=$(echo ${VERSION_MANIFEST} | jq -r .mainClass)}
INSTANCES="${PWD}/instances"
if [ -f "playtime/${INAME}" ]; then
PRVTOTAL=`cat "playtime/${INAME}"`
else
PRVTOTAL=0
fi
STARTTIME=`date +"%s"`
mkdir -p "${INSTANCES}/${INAME}"
ORIGDIR="${PWD}"
cd "${INSTANCES}/${INAME}"
trap 'echo "Interrupt received"' INT
echo ${ARGUMENTS} ${XARGS} | xargs "${JAVA}" ${JARGS} -Duser.language=en -Djava.library.path="${ORIGDIR}/natives-${PLATFORM}" -cp "${CLASSPATH}" "${MAINCLASS}"
ENDTIME=`date +"%s"`
cd "${ORIGDIR}"
TOTALSECONDS=`echo ${ENDTIME} - ${STARTTIME} + ${PRVTOTAL} | nickle`
if [ ! -z ${TOTALSECONDS} ]; then # Prevent playtime from being cleared if nickle is broken/missing
mkdir -p playtime
echo ${TOTALSECONDS} > "playtime/${INAME}"
echo Total playtime: ${ENDTIME} - ${STARTTIME} + ${PRVTOTAL} = ${TOTALSECONDS}
fi
|