├── .gitignore ├── README.md └── modRemapper.sh /.gitignore: -------------------------------------------------------------------------------- 1 | mappings 2 | tiny-remapper 3 | *.jar -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ModRemapper 2 | Automagically downloads the correct mappings for the specified game version, downloads tiny-remapper and remaps the given jar from intermediary to named. 3 | 4 | ## Usage 5 | `modRemapper.sh ` 6 | 7 | Example: `modRemapper.sh input.jar 1.19.3+build.5` to remap `input.jar`, which used `1.19.3+build.5` mappings, from intermediary to named mappings. 8 | 9 | The mapped output jarfile will be located in the same directory as the input jarfile, with the `-remapped` suffix. Ex. for `input.jar`: `input-remapped.jar` -------------------------------------------------------------------------------- /modRemapper.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | return_code_neq_failhard() { 4 | if [ $? -ne "$1" ]; then 5 | echo "$2" 6 | exit 1 7 | fi 8 | } 9 | 10 | if ! command -v git &> /dev/null; then 11 | echo "[!] The git command couldn't be found. Install git first, then re-run the script." 12 | exit 1 13 | fi 14 | 15 | if ! command -v curl &> /dev/null; then 16 | echo "[!] The curl command couldn't be found. Install curl first, then re-run the script." 17 | exit 1 18 | fi 19 | 20 | if [ "$JAVA_HOME" != "" ]; then 21 | JAVA_PATH="$JAVA_HOME/bin/java" 22 | else 23 | JAVA_PATH=$(command -v java) 24 | fi 25 | 26 | if [ ! "$JAVA_PATH" ]; then 27 | echo "[!] Java couldn't be found. Please first install java or set JAVA_HOME, then re-run the script." 28 | exit 1 29 | fi 30 | if [ ! -f "$JAVA_PATH" ]; then 31 | echo "[!] $JAVA_HOME points to an invalid JRE installation. Please make sure that $JAVA_HOME/bin/java exists" 32 | exit 1 33 | fi 34 | 35 | BASE_DIR=$(readlink -f "$(dirname -- "$0")") 36 | r1=$? 37 | GIT_PATH=$(command -v git) 38 | r2=$? 39 | if [ $r1 -ne 0 ] || [ $r2 -ne 0 ]; then 40 | echo "[!] fatal: Failed to set up. dirname exit code: $r1. pwd exit code: $r2" 41 | exit 1 42 | fi 43 | 44 | echo "[#] Base directory is $BASE_DIR" 45 | echo "[#] Git @ $GIT_PATH" 46 | echo "[#] Java @ $JAVA_PATH" 47 | 48 | if [ "$#" -lt 2 ]; then 49 | echo "Syntax: modRemapper.sh modJarfile.jar mappingsToUse" 50 | echo "Example: modRemapper.sh modJarfile.jar 1.19.3+build.5 # mod compiled for minecraft 1.19.3, use 5th build of mappings. See https://fabricmc.net/develop/" 51 | exit 0 52 | fi 53 | 54 | INP_JAR="$1" 55 | GAME_VERSION="$2" 56 | TMP_DIR=".tmp" 57 | echo "[#] Input jarfile is $INP_JAR" 58 | echo "[#] Game version is $GAME_VERSION" 59 | 60 | if [ ! -f "$INP_JAR" ]; then 61 | echo "[!] fatal: Input jarfile does not exist or is not a file" 62 | exit 1 63 | fi 64 | 65 | MAPPINGS_LOC="$BASE_DIR/$TMP_DIR/mappings/mappings.tiny" 66 | MAPPINGS_URL="https://maven.fabricmc.net/net/fabricmc/yarn/$GAME_VERSION/yarn-$GAME_VERSION-v2.jar" 67 | 68 | echo "[+] Getting mappings @ $MAPPINGS_URL ..." 69 | if [ "200" != "$(curl -LI "$MAPPINGS_URL" -o /dev/null -w '%{http_code}\n' -s)" ]; then 70 | echo "[!] Server returned non-200 code, does the mappings version exist?" 71 | exit 1 72 | fi 73 | 74 | if [ -e "$BASE_DIR/$TMP_DIR" ]; then 75 | rm -vr "${BASE_DIR:-"."}/${TMP_DIR:-"the_void_aabbcc123123123"}" # be VERY careful here 76 | fi 77 | mkdir -p "$BASE_DIR/$TMP_DIR" 78 | OUT_JF="$BASE_DIR/$TMP_DIR/mappings-$GAME_VERSION.jar" 79 | 80 | curl -L --progress-bar "$MAPPINGS_URL" -o "$OUT_JF" 81 | return_code_neq_failhard 0 "[!] Failed to download mappings. Please report this as a bug." 82 | 83 | unzip -q "$OUT_JF" -d "$BASE_DIR/$TMP_DIR" 84 | 85 | TINY_REMAPPER_LOC="$BASE_DIR/tiny-remapper.jar" 86 | if [ ! -f "$TINY_REMAPPER_LOC" ]; then 87 | echo "[+] Downloading tiny-remapper..." 88 | curl -L --progress-bar "https://maven.fabricmc.net/net/fabricmc/tiny-remapper/0.8.6/tiny-remapper-0.8.6-fat.jar" -o "$TINY_REMAPPER_LOC" 89 | return_code_neq_failhard 0 "[!] Failed to download tiny-remapper. Please report this as a bug." 90 | fi 91 | 92 | echo "[+] Running tiny-remapper" 93 | OUT_JAR="$(dirname "$INP_JAR")/$(basename "$INP_JAR" ".jar")-remapped.jar" 94 | "$JAVA_PATH" -jar "$TINY_REMAPPER_LOC" "$INP_JAR" "$OUT_JAR" "$MAPPINGS_LOC" "intermediary" "named" 95 | return_code_neq_failhard 0 "[!] Failed to remap. Not sure how to continue from here..." 96 | 97 | echo "[+] Done remapping! Remapped jarfile @ $OUT_JAR" 98 | rm -r "$BASE_DIR/.tmp" --------------------------------------------------------------------------------