Since setting up the original Minecraft server on Google Cloud Platform, I’ve been constantly trying to find ways to lower the monthly cost. A 10 user Minecraft Realms server can be hosted by Mojang for the low price of $7.99/month. A Minecraft themed hosted VPS can typically be found for around $40/month. So seeing server bills of $135-150/month on Google Cloud is completely out of reasonable budget range and expectations. To be fair, I did receive some recommendations on signiciantly lowering the cost by:
- Using a Preemptable Virtual Machine on GCP – This would not work well for a service I wanted to keep up on demand for players to access, as they could be in the middle of a session and if the server got preempted, it would need to shut down with little notice.
- Shutting the server down when not in use – I started writing a script to take care of this, but code refactoring is still in progress. I will share the script when it is finished.
Purchasing a new on-premise server that had the capacity to host Minecraft locally was also factored into the motivation to upgrade my on-premise server. There have been a few asks from players for more/different mods than what is currently running on the PaperMC server. I’ve purposefully tried to keep the experience as close to Vanilla Minecraft as possible, while maintaining stability and performance. I’ve added a few quality of life plugins, but nothing too outlandish.
While planning to migrate the existing PaperMC server from Google Cloud to on-prem, I also decided to build a Minecraft server network. This would allow the players to connect to one server address, and access multiple Minecraft servers. I decided to set up the following virtual machines to separate the Minecraft servers:
- minecraft-proxy would run a Velocity Proxy, which I found has the best compatibility between Paper and Forge. This will handle the initial connection from the player and then pass them off to the servers.
- minecraft-lobby would run a 1.16.3 PaperMC Vanilla Lobby with some plugins and tweaks. Eventually I’d like this to be the entry world with portals to connect to the other servers.
- minecraft-vanilla will be the 1.16.3 PaperMC Vanilla world currently running on Google Cloud Platform. I will transfer the world files here and run it locally.
- minecraft-forge would run a Minecraft Forge modpack. I chose to go with Roguelike Adventures and Dungeons as I was interested in trying out the Twilight Forest mod, and I enjoy caving and exploring more than I do building. There are a number of other mods in this modpack that appealed to me and met the requests from some of the other players.
I’ve set up the virtual machines on their own DMZ VLAN, using a separate NIC on the system to completely isolate it from the rest of the servers.
I set up a DMZ network on my pfSense firewall and configured the physical ports on the switches for this network to allow the traffic to get to it. I set up port forwarding for the Minecraft server to connect to the Minecraft Velocity Proxy. I had to allow UDP Ports 19132 and 19133 as well as the Minecraft server port, in order for users to be able to connect.
I installed each of the Minecraft VMs with Debian Buster, added some basic utilities and Java, installed the basic setup for each server. There were a few tweaks needed to get everything running properly:
- Switching between the Velocity Proxy, the Lobby, and Vanilla server with a stock 1.16.3 client worked very well. I had to configure player information Legacy forwarding and make a few tweaks to the server.properties files on each server based on the instructions. This all worked quite smoothly.
- The Minecraft Forge 1.12.2 server proved to be trickier to get working. Getting the base modpack installed was as easy as downloading and unzipping the file, however getting it to talk to the proxy proved a bit more difficult. I needed to install SpongeForge 1.12.2 on the server in order for it to talk to the Velocity proxy. I then edited the config/sponge/global.conf file to set up Sponge to understand the data forwarded from Velocity based on the instructions. In order to start up the Forge server without crashing, I had to rename the SpongeForge JAR to aaa_spongeforge-1.12.2-2838-7.3.0.jar so it would load first. I also had to upgrade the Just Enough IDs mod to version 1.0.3-55 to address an incompatibility with Sponge, and also upgrade VanillaFix to 1.0.10-150. Once I did this, I was able to start the server without core dumping.
- Originally I had the velocity.toml file set to bring all users to the Lobby first. Because the players will be connecting to the same proxy with a 1.16.3 or a 1.12.2 client, I had to install ViaBackwards and ViaVersion on the Lobby server, so users with an older client could connect to a newer server. Even so, the client and server would both choke pretty hard during the connection attempt as the mods would be disabled. I solved this by setting the Velocity Proxy to try the modded server first, then the vanilla server, and finally the lobby server – in that order.
- If a user connected with a 1.12.2 modded client, they would be able to connect to the minecraft-forge server without issue. If a user connected with a 1.16.3 unmodded client, they would fail to connect to the minecraft-forge server, and connect to the minecraft-vanilla server as a second choice. The Lobby is available, but will need some more work before it gets more use.
- In the meantime, the users can use these commands to access the various servers: “/server vanilla”, “/server modded”, “/server lobby”.
Now that the servers were all set up, I had some problems with the modded client not being able to connect due to the changes I made to the modpack. I had downloaded and installed MultiMC to use with the modpack, and there is a client download to install as a zip, however I had to make some changes and publish my own package:
- I had to update the Just Enough IDs mod to 1.0.3-55 to match the server. I ran into a lot of client crashes as soon as I did this due to Mixin compatibility issues. I got a lot of help from the Velocity, Sponge, and MultiMC Discords, and it was solved by renaming the file to AAA_JustEnoughIDs-1.0.3-55.jar so it would load in first.
- I also had to update to VanillaFix-1.0.10-150.jar to get the client to load fully without crashing.
- I added in OptiFine_1.12.2_HD_U_F5.jar to allow for some more advanced graphical options and efficiency. I tried added in a shader pack as well, but the client would freeze when trying to apply it, so we may be stuck with the base shaders. There are some issues with shader packs used with this mod anyway, so it’s probably better not to use them.
- I exported my MultiMC setup and created my own template for the users to use. We’ll see how well this works.
I’m sure I will have more to share about this new setup, and all of the servers need a lot of work to get them properly set up with daemons, backups, and automated configurations, but it’s a good start.