diff --git a/build_forge.gradle b/build_forge.gradle index cc55eb41cf..ceb0ed78af 100644 --- a/build_forge.gradle +++ b/build_forge.gradle @@ -724,6 +724,20 @@ tasks.register('installerJson', InstallerJson) { '--task', 'EXTRACT_FILES', '--archive', '{INSTALLER}', + '--from', 'data/README.txt', + '--to', '{ROOT}/README.txt', + + '--from', 'data/run.sh', + '--to', '{ROOT}/run.sh', + '--exec', '{ROOT}/run.sh', + + '--from', 'data/run.bat', + '--to', '{ROOT}/run.bat', + + '--from', 'data/user_jvm_args.txt', + '--to', '{ROOT}/user_jvm_args.txt', + '--optional', '{ROOT}/user_jvm_args.txt', + '--from', 'data/unix_args.txt', '--to', "{ROOT}/libraries/${MAVEN_PATH}/unix_args.txt", @@ -894,6 +908,12 @@ tasks.register('installerJar', InstallerJar) { rename { 'win_args.txt' } } + from(rootProject.file('server_files')) { + filter(tokens, ReplaceTokens) + into 'data' + exclude 'args.txt' + } + jarSigner.sign(it) } diff --git a/server_files/README.txt b/server_files/README.txt new file mode 100644 index 0000000000..1d1cd235bf --- /dev/null +++ b/server_files/README.txt @@ -0,0 +1,52 @@ +If you need help with your Forge server, join our Discord or forums: +- https://discord.minecraftforge.net +- https://forums.minecraftforge.net + +Quick start guide +================= +The steps will vary depending on if you're self-hosting or using a hosting provider: + +Self-hosting +------------ +On Windows, start the server by double-clicking the run.bat file. +On Linux or macOS, start the server by running the run.sh script. + +- To change the amount of RAM allocated to the game, edit the user_jvm_args.txt file. +- To hide the GUI, edit the run.bat or run.sh file and refer to its instructions. +- To change server settings, edit the server.properties file and config files in the config folder. + +Hosting providers +----------------- +The steps will vary depending on your hosting provider and what panel they use. + +Some providers require you to install Forge through an option in their panel, others require you to upload the files +yourself and select a jar file. It's recommended to install Forge through the panel if possible, as it'll be easier. + +If you need to select a jar file, upload your Forge server install (all files in the folder this readme is in) and +select the shim jar file. + +If you're unsure, contact your hosting provider's or server panel's support. + +Performance tuning +================== +Here are some tips and advice to improve server performance: + +- Use the latest version of MC, Forge and mods when possible. Newer versions usually have performance improvements. + +- Turn down the view distance and simulation distance in the server.properties file. Simulation distance should be the + same as or marginally lower than view distance. + +- Don't allocate excessive amounts of RAM to the game - especially if self-hosting. Too much can cause lag, as it could + cause resource contention with other things running on the same machine, such as the OS, drivers and other apps. + +- When using custom JVM args, test the before and after. There isn't a one-size-fits-all solution, and some settings + might make things worse with your specific hardware and combination of mods. + +- Use a profiler (such as the Spark mod by lucko) to find the cause of lag. Some mods may be poorly optimised or simply + do a lot of things. When you find the cause, you may want to disable that specific part of the mod in its config file, + check for an update, report the issue to the mod author, find an alternative and/or remove the mod entirely. + +- Contrary to popular belief, modern Minecraft isn't single-threaded. After a certain amount of RAM, you may get better + performance from adding more fast CPU cores rather than adding more RAM. + +For more help with performance, please ask on the forums or Discord. diff --git a/server_files/run.bat b/server_files/run.bat new file mode 100644 index 0000000000..bc7e3092c4 --- /dev/null +++ b/server_files/run.bat @@ -0,0 +1,16 @@ +@echo off +REM Add custom JVM arguments (such as RAM allocation) to the user_jvm_args.txt + +java -jar @SHIM_JAR_FILE@ --onlyCheckJava +if %ERRORLEVEL% NEQ 0 ( + echo. + echo Java check failed. + echo If you're struggling to get Java to work, ask for help on the forums or Discord mentioned in the readme. + goto :exit +) + +REM Add custom program arguments (such as nogui) to the next line before the %* or pass them to this script directly +java @libraries/@MAVEN_PATH@/win_args.txt %* + +:exit +pause diff --git a/server_files/run.sh b/server_files/run.sh new file mode 100644 index 0000000000..5c89a8b259 --- /dev/null +++ b/server_files/run.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +# Add custom JVM arguments (such as RAM allocation) to the user_jvm_args.txt + +java -jar @SHIM_JAR_FILE@ --onlyCheckJava || exit 1 + +# Add custom program arguments (such as nogui) to the next line before the "$@" or pass them to this script directly +java @user_jvm_args.txt @libraries/@MAVEN_PATH@/unix_args.txt "$@" diff --git a/server_files/user_jvm_args.txt b/server_files/user_jvm_args.txt new file mode 100644 index 0000000000..d33548d38f --- /dev/null +++ b/server_files/user_jvm_args.txt @@ -0,0 +1,10 @@ +# Note: Not all server panels support this file. You may need to set these options in the panel itself. + +# Xmx and Xms set the maximum and minimum RAM usage, respectively. +# They can take any number, followed by an M (for megabyte) or a G (for gigabyte). +# For example, to set the maximum to 3GB: -Xmx3G +# To set the minimum to 2.5GB: -Xms2500M + +# A good default for a modded server is 4GB. Do not allocate excessive amounts of RAM as too much may cause lag or crashes. +# Uncomment the next line to set it. To uncomment, remove the # at the beginning of the line. +# -Xmx4G diff --git a/settings.gradle b/settings.gradle index 7a5612b413..ef4b6247f3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -28,7 +28,7 @@ dependencyResolutionManagement { library('forgespi', 'net.minecraftforge:forgespi:7.1.3') // Needs modlauncher library('bootstrap', 'net.minecraftforge:bootstrap:2.0.0') // Needs modlauncher library('bootstrap-api', 'net.minecraftforge:bootstrap-api:2.0.0') - library('bootstrap-shim', 'net.minecraftforge:bootstrap-shim:2.0.1') + library('bootstrap-shim', 'net.minecraftforge:bootstrap-shim:2.0.2') library('modlauncher', 'net.minecraftforge:modlauncher:10.1.2') // Needs securemodules library('securemodules', 'net.minecraftforge:securemodules:2.2.10') // Needs unsafe library('unsafe', 'net.minecraftforge:unsafe:0.9.2')