Advertisement
katubug

Untitled

Mar 20th, 2025 (edited)
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #!/bin/sh
  2. set -eu
  3. FORGE_VERSION=43.4.6
  4. # To use a specific Java runtime, set an environment variable named CWITCH_JAVA to the full path of java.exe.
  5. # To disable automatic restarts, set an environment variable named CWITCH_RESTART to false.
  6. # To install the pack without starting the server, set an environment variable named CWITCH_INSTALL_ONLY to true.
  7. INSTALLER="forge-1.19.2-$FORGE_VERSION-installer.jar"
  8. FORGE_URL="https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.19.2-$FORGE_VERSION/forge-1.19.2-$FORGE_VERSION-installer.jar"
  9.  
  10. pause() {
  11. printf "%s\n" "Press enter to continue..."
  12. read ans
  13. }
  14.  
  15. if ! command -v "${CWITCH_JAVA:-java}" >/dev/null 2>&1; then
  16. echo "Minecraft 1.19 requires Java 17 - Java not found"
  17. pause
  18. exit 1
  19. fi
  20.  
  21. cd "$(dirname "$0")"
  22. if [ ! -d libraries ]; then
  23. echo "Forge not installed, installing now."
  24. if [ ! -f "$INSTALLER" ]; then
  25. echo "No Forge installer found, downloading now."
  26. if command -v wget >/dev/null 2>&1; then
  27. echo "DEBUG: (wget) Downloading $FORGE_URL"
  28. wget -O "$INSTALLER" "$FORGE_URL"
  29. else
  30. if command -v curl >/dev/null 2>&1; then
  31. echo "DEBUG: (curl) Downloading $FORGE_URL"
  32. curl -o "$INSTALLER" -L "$FORGE_URL"
  33. else
  34. echo "Neither wget or curl were found on your system. Please install one and try again"
  35. pause
  36. exit 1
  37. fi
  38. fi
  39. fi
  40.  
  41. echo "Running Forge installer."
  42. "${CWITCH_JAVA:-java}" -jar "$INSTALLER" -installServer
  43. fi
  44.  
  45. if [ ! -e server.properties ]; then
  46. printf "allow-flight=true\nmax-tick-time=-1" > server.properties
  47. fi
  48.  
  49. if [ "${CWITCH_INSTALL_ONLY:-false}" = "true" ]; then
  50. echo "INSTALL_ONLY: complete"
  51. exit 0
  52. fi
  53.  
  54. JAVA_VERSION=$("${CWITCH_JAVA:-java}" -fullversion 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d'.' -f1)
  55. if [ ! "$JAVA_VERSION" -ge 17 ]; then
  56. echo "Minecraft 1.19 requires Java 17 - found Java $JAVA_VERSION"
  57. pause
  58. exit 1
  59. fi
  60.  
  61. while true
  62. do
  63. "${CWITCH_JAVA:-java}" @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.19.2-$FORGE_VERSION/unix_args.txt nogui
  64.  
  65. if [ "${CWITCH_RESTART:-true}" = "false" ]; then
  66. exit 0
  67. fi
  68.  
  69. echo "Restarting automatically in 10 seconds (press Ctrl + C to cancel)"
  70. sleep 10
  71. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement