From e6a9a80f274b3364791072d7c77927170ced95c1 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Mon, 9 May 2022 23:33:34 -0700 Subject: [PATCH] Add pregen automation --- homelab/server/config/minecraft/README.md | 32 +++++++++++++++++++---- homelab/server/config/minecraft/bmcp.yml | 6 +++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/homelab/server/config/minecraft/README.md b/homelab/server/config/minecraft/README.md index dc781200..7aae38cf 100644 --- a/homelab/server/config/minecraft/README.md +++ b/homelab/server/config/minecraft/README.md @@ -1,7 +1,10 @@ ## Connecting to a server's CLI -`docker exec -it rcon-cli --password thanksitzg` -https://github.com/itzg/docker-minecraft-server#interactive-and-color-console -https://github.com/itzg/docker-minecraft-server#use-rcon-commands +To connect to a server's RCON Minecraft console, run +`docker exec -it minecraft_e6 rcon-cli --password thanksitzg` +Do not prefix commands with `/`. + +- https://github.com/itzg/docker-minecraft-server#interactive-and-color-console +- https://github.com/itzg/docker-minecraft-server#use-rcon-commands ## Updating MC-Router mappings MC-Router must be running for all active MC connections. Restarting it kicks everyone off their servers @@ -19,8 +22,11 @@ Check the following server.properties values: | `rcon.port` | `25575` | Set this to what itzg's rcon-cli expects as default | | `view-distance` | 10 for lightweight servers, 6 for heavy servers | View distance has great impact on server load | -## Pregenerating Chunks +## Chunk Pregenerator +Chunk pregeneration is very valuable for getting a playable SMP server expierence. +### Installing Chunk Pregenerator Make sure that the [Chunk Pregenerator](https://www.curseforge.com/minecraft/mc-mods/chunkpregenerator) mod is installed. It is compatible with most Minecraft versions between 1.7.2 and 1.16.5. +### Pregenerating World Spawn To pregen chunks, first connect to the server's RCON CLI. Then, run the following, `pregen start gen radius Pregen SQUARE 0 0 100` This should take about half an hour and will generate about 40,000 chunks (2r^2). @@ -28,4 +34,20 @@ For a job closer to 8 hours, run `pregen start gen radius Pregen SQUARE 0 0 500` Which will generate about 500,000 chunks. -A Ryzen 7 5800X generates chunks at about 1.35 chunks per tick (27 chunks per second @ 20 TPS). \ No newline at end of file +A Ryzen 7 5800X generates chunks at about 1.35 chunks per tick (27 chunks per second @ 20 TPS). + +### Automating Chunk Pregen +Itzg's [container supports](https://github.com/itzg/docker-minecraft-server#use-rcon-commands) `RCON_CMDS_FIRST_CONNECT` and `RCON_CMDS_LAST_DISCONNECT` environment variables, which allow us to automatically begin pregenerating chunks when no one is connected, and pause this task when players begin joining. + +Use these variables when the server supports pregen and would benefit from this: +``` +RCON_CMDS_STARTUP= |- + /pregen start gen radius Pregen SQUARE 0 0 500 +RCON_CMDS_FIRST_CONNECT= |- + /pregen pause +RCON_CMDS_LAST_DISCONNECT= |- + /pregen continue +``` +This pregen will significantly reduce load on the server during playtime *unless*: +* Players explore beyond the pregenerated regions, or +* Players join the server before a significant area can be pregenerated. diff --git a/homelab/server/config/minecraft/bmcp.yml b/homelab/server/config/minecraft/bmcp.yml index ca973e89..bb9267fd 100644 --- a/homelab/server/config/minecraft/bmcp.yml +++ b/homelab/server/config/minecraft/bmcp.yml @@ -14,6 +14,12 @@ services: - ENABLE_RCON=true # This does not override server.properties - RCON_PORT=25575 # This does not override server.properties - RCON_PASSWORD=${RCON_PASSWORD} # This does not override server.properties + - RCON_CMDS_STARTUP= |- + /pregen start gen radius Pregen SQUARE 0 0 500 + - RCON_CMDS_FIRST_CONNECT= |- + /pregen pause + - RCON_CMDS_LAST_DISCONNECT= |- + /pregen continue volumes: - $DOCKER_DATA/bmcp:/data:rw networks: