2016-04-02 03:55:54 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-12-30 04:40:32 +00:00
|
|
|
|
2016-04-03 07:23:19 +00:00
|
|
|
(
|
|
|
|
set -e
|
2015-12-30 04:40:32 +00:00
|
|
|
PS1="$"
|
2016-04-03 08:35:51 +00:00
|
|
|
basedir="$(cd "$1" && pwd -P)"
|
2016-04-02 03:55:54 +00:00
|
|
|
workdir="$basedir/work"
|
|
|
|
minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
2018-07-21 12:09:40 +00:00
|
|
|
windows="$([[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]] && echo "true" || echo "false")"
|
2017-08-12 23:56:59 +00:00
|
|
|
decompiledir="$workdir/Minecraft/$minecraftversion"
|
2016-04-02 03:55:54 +00:00
|
|
|
classdir="$decompiledir/classes"
|
2015-12-30 04:40:32 +00:00
|
|
|
echo "Extracting NMS classes..."
|
|
|
|
if [ ! -d "$classdir" ]; then
|
|
|
|
mkdir -p "$classdir"
|
|
|
|
cd "$classdir"
|
|
|
|
jar xf "$decompiledir/$minecraftversion-mapped.jar" net/minecraft/server
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
cd "$basedir"
|
|
|
|
echo "Failed to extract NMS classes."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Decompiling classes..."
|
|
|
|
if [ ! -d "$decompiledir/net/minecraft/server" ]; then
|
|
|
|
cd "$basedir"
|
2016-04-02 03:55:54 +00:00
|
|
|
java -jar "$workdir/BuildData/bin/fernflower.jar" -dgs=1 -hdc=0 -asc=1 -udv=0 "$classdir" "$decompiledir"
|
2015-12-30 04:40:32 +00:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "Failed to decompile classes."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2018-07-21 12:09:40 +00:00
|
|
|
|
|
|
|
# set a symlink to current
|
|
|
|
currentlink="$workdir/Minecraft/current"
|
|
|
|
if ([ ! -e "$currentlink" ] || [ -L "$currentlink" ]) && [ "$windows" == "false" ]; then
|
2018-08-24 01:50:36 +00:00
|
|
|
set +e
|
2018-07-21 12:09:40 +00:00
|
|
|
echo "Pointing $currentlink to $minecraftversion"
|
2018-08-24 01:50:36 +00:00
|
|
|
rm -rf "$currentlink" || true
|
|
|
|
ln -sfn "$minecraftversion" "$currentlink" || echo "Failed to set current symlink"
|
2018-07-21 12:09:40 +00:00
|
|
|
fi
|
|
|
|
|
2016-04-03 07:23:19 +00:00
|
|
|
)
|