Skip to content

Commit ffe95a9

Browse files
authored
Merge pull request #11 from xathon/main
Add an automatic way to fix Forge 1.17+ files
2 parents 161514c + 30f31f0 commit ffe95a9

File tree

1 file changed

+48
-20
lines changed
  • docs/mscs/adjusting-world-server-properties

1 file changed

+48
-20
lines changed

docs/mscs/adjusting-world-server-properties/forge.md

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,34 @@ is the name of your world.
100100
## Forge 1.17.1 and later
101101
Please note that forge for Minecraft 1.17.1 will be used in the examples. If you named the server directory `forge-1.17.1` in the first step with the `mkdir` command, the installer should install a bash script to `/opt/mscs/server/forge-1.17.1` and a bunch of library files in `/opt/mscs/server/forge-1.17.1/libraries/`.
102102

103-
In the `/opt/mscs/server/forge-1.17.1 directory`, edit `run.sh`.
103+
There's an automatic and a manual way to apply the fixes needed for these versions.
104+
105+
### Automatic
106+
107+
**In the `/opt/mscs/server/forge-1.17.1` directory**, execute these commands:
108+
109+
```bash
110+
sed -i "\|@[^\"]|s|@|@$(pwd)/|" run.sh
111+
sed -i "s|\"\$@|--nogui &|g" run.sh
112+
sed -i "s|libraries|$(pwd)/libraries|g" libraries/net/minecraftforge/forge/*/unix_args.txt
113+
```
114+
115+
<details>
116+
<summary>Explanation of the sed commands</summary>
117+
118+
`sed -i "\|@[^\"]|s|@|@$(pwd)/|" run.sh`: This matches all occurences of `@` that aren't followed by `"` and adds the current directory followed by a / to it (or rather, replaces the `@` with an `@` followed by the current directory).
119+
120+
`sed -i "s|\"\$@|--nogui &|g" run.sh`: This adds `--nogui ` in front of `"$@`, with `&` being the matched pattern.
121+
122+
`sed -i "s|libraries|$(pwd)/libraries|g" libraries/net/minecraftforge/forge/*/unix_args.txt`: This adds the current path to all occurences of the word libraries in the unix_args.txt file. Because the directory contains the forge version (for example `1.17.1-37.1.1`), `*` is used as a wildcard.
123+
124+
</details>
125+
<br>
126+
Continue below at <a href="#end-manual"><strong>You may also want...</strong></a>
127+
128+
### Manual
129+
130+
In the `/opt/mscs/server/forge-1.17.1` directory, edit `run.sh`.
104131

105132
(GNU nano is an easy to use command-line text editor if you plan to edit the file from the terminal. Install it with `sudo apt install nano` if you are using a Debian based distro. In the following instructions, to edit a file with GNU nano, replace `editor` with `nano`.)
106133

@@ -122,6 +149,25 @@ The `@user_jvm_args.txt` and the `@libraries/net/minecraftforge/forge/1.17.1-37.
122149
java @/opt/mscs/server/forge-1.17.1/user_jvm_args.txt @/opt/mscs/server/forge-1.17.1/libraries/net/minecraftforge/forge/1.17.1-37.1.1/unix_args.txt --nogui "$@"
123150
```
124151

152+
Now the `unix_args.txt` file mentioned in `run.sh` needs to be edited as well to include the full directory paths. Change the directory to the one containing the `unix_args.txt` file, create a backup in case you mess up the editing, and then edit the original.
153+
154+
```bash
155+
cd /opt/mscs/server/forge-1.17.1/libraries/net/minecraftforge/forge/1.17.1-37.1.1/
156+
cp unix_args.txt unix_args_backup.txt
157+
editor unix_args.txt
158+
```
159+
160+
Every path that includes `libraries/[...]` has to be replaced with their full directory path: `/opt/mscs/server/forge-1.17.1/libraries/[...]`. If your editor of choice is GNU nano, this can be done by pressing `<Ctrl-\>`, typing `libraries` and pressing enter, then typing the full path name. In this case it would be `/opt/mscs/server/forge-1.17.1/libraries`, then press enter, then press `<a>` to replace all.
161+
162+
If you mess this up, you can always delete the `unix_args.txt` file and make another one using the backup, and start editing again.
163+
164+
```bash
165+
rm unix_args.txt
166+
cp unix_args_backup.txt unix_args.txt
167+
editor unix_args.txt
168+
```
169+
<a id="end-manual"></a>
170+
125171
You may also want to increase the initial RAM and possibly even the maximum RAM. To do this, edit the `user_jvm_args.txt` file.
126172

127173
```bash
@@ -143,24 +189,6 @@ Now add all the java arguments you wish. For example, to allocate a minimum of 4
143189
-Xms4G -Xmx6G
144190
```
145191

146-
Now the `unix_args.txt` file mentioned in `run.sh` needs to be edited as well to include the full directory paths. Change the directory to the one containing the `unix_args.txt` file, create a backup in case you mess up the editing, and then edit the original.
147-
148-
```bash
149-
cd /opt/mscs/server/forge-1.17.1/libraries/net/minecraftforge/forge/1.17.1-37.1.1/
150-
cp unix_args.txt unix_args_backup.txt
151-
editor unix_args.txt
152-
```
153-
154-
Every path that includes `libraries/[...]` has to be replaced with their full directory path: `/opt/mscs/server/forge-1.17.1/libraries/[...]`. If your editor of choice is GNU nano, this can be done by pressing `<Ctrl-\>`, typing `libraries` and pressing enter, then typing the full path name. In this case it would be `/opt/mscs/server/forge-1.17.1/libraries`, then press enter, then press `<a>` to replace all.
155-
156-
If you mess this up, you can always delete the `unix_args.txt` file and make another one using the backup, and start editing again.
157-
158-
```bash
159-
rm unix_args.txt
160-
cp unix_args_backup.txt unix_args.txt
161-
editor unix_args.txt
162-
```
163-
164192
Create a new server (if necessary):
165193

166194
```bash
@@ -208,7 +236,7 @@ mscs stop forge
208236
mscs start forge
209237
```
210238

211-
The server should start up and run
239+
The server should start up and run.
212240

213241
The server startup can be monitored by running:
214242

0 commit comments

Comments
 (0)