Categories
devops minecraft

Create a Modded Minecraft Server on a hosted Kubernetes Cluster

Previous Post: Create a Kubernetes Cluster on Oracle Cloud for free using Terraform

Credit: This guy is the man, https://github.com/itzg . He maintains https://github.com/itzg/minecraft-server-charts/tree/master/charts/minecraft which is just an epic Minecraft Helm chart.

If you already have a Kubernetes cluster that’s perfect, if not you can follow the previous post to get one for free on Oracle Cloud.

If you are not using Oracle cloud you will need to modify the minecraft/_terraform.tf file slightly to use whatever storage backend you want for the terraform state file.

So change:

backend "oci" {}

to something like

backend "s3" {}

Or whatever your preference might be. See https://developer.hashicorp.com/terraform/language/backend if you need guidance on how to choose and what it means.

Check out the repository https://github.com/saranicole/minecraft-oci-k8s with git. We will be using the minecraft directory.

git clone https://github.com/saranicole/minecraft-oci-k8s.git
cd oci-free-cloud-k8s/terraform/minecraft

You will need to create a backend.conf file, a general.auto.tfvars, a minecraft.auto.tfvars file and possibly an oracle.auto.tfvars file. Depending on how you want this to end up you will put different contents into these tfvars files.

backend.conf

namespace = "<<Storage Namespace>>"
bucket    = "terraform-states"
key       = "infra/minecraft.tfstate"

general.auto.tfvars

chart_version = "5.1.2"

If you are using Oracle Cloud, create the oracle.auto.tfvars file.

oracle.auto.tfars

compartment_id = << Tenancy OCID >>
region = << Region >>
ssh_public_key = << SSH Public Key >>
user_ocid = << User OCID >>
fingerprint = << API Key fingerprint >>
private_key_path = << Path to API Key Secret File >>
bucket_namespace = << Storage Namespace >>

If you want a vanilla Minecraft server, use the structure below and tweak as needed (making sure to change accept_eula to TRUE):

# Change this to TRUE
accept_eula = "FALSE"
world_version = "26.1.1"
server_type = "VANILLA"
fabric_loader_version = "0.18.6"
difficulty = "easy"
whitelist = "<< YOUR MINECRAFT USERNAME >>,<< SOME OTHER MINECRAFT USERNAME >>"
ops = "<< YOUR MINECRAFT USERNAME >>,<< SOME OTHER MINECRAFT USERNAME >>"
motd = "Welcome to Minecraft on Kubernetes!"
mod_urls = [
  "<< MODRINTH JAR DIRECT DOWNLOAD URL >>",
  "<< SOME OTHER JAR DIRECT DOWNLOAD URL >>"
]
download_world_url = "<< DIRECT DOWNLOAD LINK OF ZIP FILE CONTAINING WORLD DATA >>"
rclone_dest_dir = "<< OBJECT STORAGE BUCKET SUCH AS S3 OR OCI BUCKET NAME >>/<< OBJECT STORAGE BUCKET PREFIX SUCH AS 'worlds' >>"
enable_oci_backup_bucket = false
enable_oci_load_balancer = false
rcon_password = "<< SUPER SECRET PASSWORD >>"

If you want Cobblemon, particularly cobblemon on Meta Quest, you will need to use contents like the following:

minecraft.auto.tfvars

# Change this to TRUE
accept_eula = "FALSE"
world_version = "1.21.1"
server_type = "FABRIC"
fabric_loader_version = "0.18.6"
difficulty = "easy"
whitelist = "<< YOUR MINECRAFT USERNAME >>,<< SOME OTHER MINECRAFT USERNAME >>"
ops = "<< YOUR MINECRAFT USERNAME >>,<< SOME OTHER MINECRAFT USERNAME >>"
motd = "Welcome to Cobblemon on Kubernetes!"
mod_urls = [
"https://cdn.modrinth.com/data/MdwFAVRL/versions/Ygf8KJFC/Cobblemon-fabric-1.7.0%2B1.21.1.jar",
"https://cdn.modrinth.com/data/P7dR8mSH/versions/yGAe1owa/fabric-api-0.116.9%2B1.21.1.jar"
]
download_world_url = "<< DIRECT DOWNLOAD LINK OF ZIP FILE CONTAINING WORLD DATA >>"
rclone_dest_dir = "<< OBJECT STORAGE BUCKET SUCH AS S3 OR OCI BUCKET NAME >>/<< OBJECT STORAGE BUCKET PREFIX SUCH AS 'worlds' >>"
enable_oci_backup_bucket = false
enable_oci_load_balancer = false
rcon_password = "<< SUPER SECRET PASSWORD >>"

If you are using Oracle, you will want to change both enable_oci_backup_bucket and enable_oci_load_balancer to true.

In the case of Oracle the rclone_dest_dir will be “minecraft-backups/worlds”.

Run the init first to confirm that Terraform is working and make sure to inspect everything it will create.

terraform init -backend-config=backend.conf

Then run the plan

terraform plan

If there are any errors due to missing information, make sure your files are all filled out correctly.

Once the plan succeeds with no errors, you can apply the Terraform.

terraform apply

Enter “yes” when it prompts you.

It should finish like this:

Apply complete! Resources: xx added, 0 changed, 0 destroyed.

At the end you will see:

Outputs:
  + my_minecraft_server_ip = "xxx.xxx.xxx.xxx"

This is your Minecraft server ip address! Connect to port 25565 with this directly, or create a friendly DNS name in your preferred way.

If connecting with the ip address you can type in these numbers in this format:

xxx.xxx.xxx.xxx:25565

I recommend https://www.duckdns.org/ as a convenient way to give your Minecraft server a friendly url.

Way to go! You now have a Minecraft server in your preferred configuration set up on your Kubernetes cluster.

Interested in more? Take a look at the last blog post in this series:

Connecting to a Cobblemon Minecraft Java Server in VR

Categories
minecraft virtual reality

Connecting to a Cobblemon Minecraft Java Server in VR

QuestCraft! It’s awesome and I highly recommend subscribing to their Patreon. To emphasize a point they make many times over, you need to own Minecraft Java Edition in order for this to work, and you need access to your Microsoft login in order to log into Minecraft.

The basic installation instructions are available at https://github.com/QuestCraftPlusPlus/QuestCraft . You will need to follow these instructions and start a single player world on version 1.21.1 first in order to have the folder created that you need to place the mod jars into. You will also want to download this jar file https://files.xrcraftmc.com/QuestCraft/Cobblemon-fabric-1.7.0%2B1.21.1.jar which is the fixed Cobblemon mod which ONLY works with Minecraft version 1.21.1 . Make sure your server is running Minecraft version 1.21.1 as well, they have not yet released a more current patched version. Everything Minecraft 1.21.1!

Also, grab the Fabric API jar at 0.116.9 – https://cdn.modrinth.com/data/P7dR8mSH/versions/yGAe1owa/fabric-api-0.116.9%2B1.21.1.jar and https://cdn.modrinth.com/data/nOK0dI1c/versions/rKDl7Dxe/request-1.0.0%2B1.21.1.jar and https://cdn.modrinth.com/data/ccKDOlHs/versions/JB1fLQnc/owo-lib-0.12.15.4%2B1.21.jar while you are at it. These are the Quest-Rebound jars which enable battling Pokemon. You will need to install all of these mods in your mods folder on your headset.

Once you have successfully connected to a single player world, you will need to back out of the game and connect to the headset using SideQuest again.

Click the folder on the top bar which is how you can navigate the Quest’s directory structure.

………………………………………. This one
…………………………………………….

Then you will want to navigate to:

Android > data > com.qcxr.qcxr > files > instances > 1.21.1 > mods

Drag the jar files you downloaded earlier into this folder:

  • Cobblemon-fabric-1.7.0 1.21.1.jar from the QuestCraft folks
  • Fabric API at 0.116.9
  • Quest Rebound
  • owo-lib

Now you should be able to connect to a Cobblemon server!

How to Battle Wild Pokemon and other Cobblemon Stuff

You will quickly find that Cobblemon relies on keybinds that are unavailable in QuestCraft. Worry not! You can use Quest Rebound to overcome this barrier.

Instructions on using Quest Rebound are quoted from the modrinth website:

Quest Rebound – Rebinding Instructions

Add this mod to your QuestCraft instance as normal and start your game. In the game, you can go to Options -> Controls -> Open VR Bindings Menu to change your keybinds.

To reset your keybinds, delete the interaction_profiles directory from your instance root.

You *must* restart your game in order for key rebinds to take effect.

Specifically for battling wild Pokemon, you can rebind “Throw Selected Pokemon” to your left controller’s x key. Make sure to uncheck its current function checkboxes before checking the Cobblemon function box.

Personally I find the left x button a good choice because its default function is to dash forward a bit, which I do not need as much as I need to battle wild Pokemon.

You could try binding the Throw action to your radial menu, but the problem is you have to interact with a Pokemon to trigger it, and left clicking the radial menu while you’re facing the it will harm the Pokemon!

So instead, bind the action to your x key, then when you want to battle a wild Pokemon, face it and press x on your left controller, and you will get the battle menu.

The “Open overlay” and other controls are fine to bind to the radial menu. To do this, click “Options”, then “VR Settings” then “Radial Menu”. Click the number that appears in the center and you will get more blank radial tiles. Click one of these tiles and you will get a bunch of actions you can assign to the tiles, including Cobblemon-related actions.

To use the radial menu once you’ve assigned it, click the y button on the right controller and it will open.

Happy Cobblemon’ing! I’m in the QuestCraft Discord server, user “saranicole1980” so feel free to ping me there if you have any questions!