diff --git a/scripts/decompile.sh b/scripts/decompile.sh index 8a9850e6db..12d5b075fc 100755 --- a/scripts/decompile.sh +++ b/scripts/decompile.sh @@ -20,7 +20,46 @@ forgefloweroptions="-dgs=1 -hdc=0 -asc=1 -udv=1 -jvn=1" forgeflowercachefile="$decompiledir/forgeflowercache" forgeflowercachevalue="$forgeflowerurl - $forgeflowerversion - $forgefloweroptions"; classdir="$decompiledir/classes" +versionjson="$workdir/Minecraft/$minecraftversion/$minecraftversion.json" +if [ ! -f "$versionjson" ]; then + echo "Downloading $minecraftversion JSON Data" + verescaped=$(echo ${minecraftversion} | sed 's/\./\\./g') + jsonurl=$(curl -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | grep -oE "https://.*?${verescaped}.json") + curl -o "$versionjson" "$jsonurl" + echo "$versionjson - $jsonurl" +fi + +function downloadLibraries { + group=$1 + groupesc=$(echo ${group} | sed 's/\./\\./g') + grouppath=$(echo ${group} | sed 's/\./\//g') + libdir="$decompiledir/libraries/${group}/" + mkdir -p "$libdir" + shift + for lib in "$@" + do + jar="$libdir/${lib}-sources.jar" + destlib="$libdir/${lib}" + if [ ! -f "$jar" ]; then + libesc=$(echo ${lib} | sed 's/\./\\]./g') + ver=$(grep -oE "${groupesc}:${libesc}:[0-9\.]+" "$versionjson" | sed "s/${groupesc}:${libesc}://g") + echo "Downloading ${group}:${lib}:${ver} Sources" + curl -s -o "$jar" "https://libraries.minecraft.net/${grouppath}/${lib}/${ver}/${lib}-${ver}-sources.jar" + set +e + grep "" "$jar" && grep -oE "