E2E Modded Minecraft Server
Tags: minecraft, server, hosting, gaming
Published: 2021-02-01 02:58:43

---
title: E2E Modded Minecraft Server
published: true
date: 2020-03-15 05:00:00 UTC
tags: minecraft,server,hosting,gaming
canonical_url: https://devops.itsltns.io/minecraft/server/hosting/gaming/ansible/2020/03/15/minecraft-server.html
---

This is the second time I have had to run through install of a minecraft client and server. I decided I need documentation this go around for the next time I want to install a modded minecraft server.

I decided to use ansible to make deployments easy. My biggest struggle was upgrading from an older version of ansible using python 2.7 to ansible 2.9.6 using python 3.5.

## Client

Getting the client setup wasn’t too difficult.

### MultiMc

I am running the Minecraft Client from my XPS workstation which runs Ubuntu 18.04.

I knew I had run Minecraft from the workstation before, but when I went to find the `.jar` client I didn’t know where it was.I couldn’t find it anywhere. I looked recursively in `/home/jack` and in `/opt`. It was nowhere to be found.

I started to install the forge client on my workstaion when I stumbled upon MultiMC which supports linux.

I then stumbled upon MultiMC already installed on my workstation with some older clients installed.

### Setting RAM

MultiMC allows to set the RAM. I have 16GB of RAM available. I allocated 8GB to the MC instance/ to JVM. I haven’t run into any issues thus far.

### Installing the E2E ModPack

Installing the Modpack was relatively simple besides the fact that the modpack is reccomended to be installed using the Twitch client. I had to find the zip file of the client. The version I wanted was [here](https://www.curseforge.com/minecraft/modpacks/enigmatica2expert/files/2889433). It was about 20MB.

The filename is a zip, `Enigmatica2Expert-1.77.zip`. In MultiMC `add an instance` and then choose a zip file modpack. Also make sure to have the correct Minecraft Version installed. This modpack uses MC 1.12.2.

## Server

The client requires 5GB, but recommends 6GB to 8GB. I wanted chunk loading and a few other compute and ram intensive features of Minecraft to run on a server so my workstation isn’t completely bogged down with processes.

The server also allows for other players to join.

### Ansible

I know I will want to spin up a MC server again and since I have done this before I have decided to create an ansible playbook for the service.

The playbook will need to be revised, but currently everything is in the common role. As I start to add more servers for games I will revise the roles for the different applications.

The directory service looks like the following:

```
.
| ____ group_vars
| | ____ all
| ____ site.yml
| ____ roles
| | ____ common
| | | ____ files
| | | | ____ forge-1.12.2-14.23.5.2847-installer.jar
| | | | ____ eula.txt
| | | | ____ mc13.service
| | | ____ tasks
| | | | ____ configure_modpack.yml
| | | | ____ main.yml
| | | | ____ install_java.yml
| | | | ____ install_forge.yml
| | | | ____ start_server.yml
| ____ hosts
| ____ host_vars

```

The `site.yml` in the playbook root directory calls the common role (`role/common/tasks/main.yml`).

The common role runs as root. Really this is a prelimenary playbook that runs everything as root. It is really a temporary server meant to be run for fun. A more permanent solution would run as a minecraft user and take more variables into account.

This example uses a server with 8gb of ram and 2 cpus.

The one note I will make on this ansible setup is that the `roles/common/tasks/configure_modpack.yml` file copies files from my user profile up to the server. (I had trouble pulling down `zip` server files..) Here is what the task looks like:

```
- name: (Configure Modpack) Copy Folder - Mods
  copy:
    src: /home/jack/.local/share/multimc/instances/Enigmatica2Expert-1.77/minecraft/mods
    dest: /root

- name: (Configure Modpack) Copy Folder - Scripts
  copy:
    src: /home/jack/.local/share/multimc/instances/Enigmatica2Expert-1.77/minecraft/scripts
    dest: /root

- name: (Configure Modpack) Copy Folder - Schematics
  copy:
    src: /home/jack/.local/share/multimc/instances/Enigmatica2Expert-1.77/minecraft/schematics
    dest: /root

- name: (Configure Modpack) Copy Folder - Resources
  copy:
    src: /home/jack/.local/share/multimc/instances/Enigmatica2Expert-1.77/minecraft/resources
    dest: /root

- name: (Configure Modpack) Copy Folder - Config
  copy:
    src: /home/jack/.local/share/multimc/instances/Enigmatica2Expert-1.77/minecraft/config
    dest: /root

- name: (Configure Modpack) Copy Folder - Manifest.json
  copy:
    src: /opt/minecraft/manifest.json
    dest: /root

- name: (Configure Modpack) Add Eula
  copy:
    src: eula.txt
    dest: /root

```

### Forge Installer vs Forge Universal

Forge installer is required to install MC Server. The Forge Universal is required to run the server.

### Turning the Minecraft Server into a Service

The service runs java from an absolute path specifying 8gb of ram allocated to the JVM pointing to a jar file at the root users directory. The `nogui` at the end specifys to forge not to open a GUI.

```
[Unit]
Description=Minecraft Server
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=never
RestartSec=1
User=root
WorkingDirectory=/root
ExecStart=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Xms8G -jar /root/forge-1.12.2-14.23.5.2847-universal.jar nogui

[Install]
WantedBy=multi-user.target

```