I have owned Minecraft Java for several years, but despite being a software developer, I have never looked into creating a mod, until now! This is certainly a different topic compared with my regular blog posts, but as always, I hope it will help someone somewhere.

I stumbled upon a video by one of the fastest-growing Minecraft YouTube channels (Dream) in which he quickly demonstrates creating some mods from suggestions in comments. My journey starts here, and with the fact that I can see an org.bukkit.event.Listener class imported.

This post should serve as a guide that works today, and I also now have a template bukkit mod on GitHub that you may find useful, as all Bukkit templates that I found were years out of date. However, perhaps I should have been looking for Spigot templates! Figuring all of this out only took an hour or so, and at the end of it, I was able to create a mod that left me with a world which you can see below.

Bukkit / Spigot Server

As far as I can tell Bukkit is the old thing, and Spigot is the new thing, and Bukkit just pointed me to follow instructions on Spigot.

The first step is to simply follow https://www.spigotmc.org/wiki/buildtools which will download all of the needed things as well as build a Minecraft Java server with Spigot-API included.

For me, on Windows, with Java already installed, this was a simple as running the commands below. (Make sure you check the wiki for prerequisites and updated instructions)

# Make somewhere to keep the code
mkdir mc && cd mc

# Download and build the latest server
curl -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar

# Agree to the EULA
echo eula=true > eula.txt

# Run the server
java -jar spigot-1.15.2.jar

At this point, you should be able to load Minecraft Java and connect to localhost which will be the server that you have just run. Once connected you can op yourself using the loaded server UI using the /op command.

Further reading:

Mod template & IDE setup

While still focusing on Bukkit, I searched around and found an outdated blog post (link), outdated templates (one, two) on GitHub and also a very verbose tutorial. Parts of the tutorial ended up being useful, but if you already know how to program then my bare-bones mod template is probably a good starting point. (Read the mod README for the most up to date guidance)

After having a working plugin I came around to realizing that Spigot templates are what I should have been searching for all along, and GitHub has some much more recently updated projects there.

# Make some directories for mod development
mkdir -p custom/mod1 && cd custom/mod1

# Clone the template and remove the .git directory
git clone https://github.com/addshore/bukkit-template-mod.git .
rm -rf ./.git

From here you can load the Mod template in your favourite IDE. Personally I use IntelliJ IDEA but Eclipse is also popular. I won’t go into details regarding how IDE setup works, but if you get stuck the verbose tutorial I mentioned earlier discusses development environments briefly. One thing you might want o do is add the JavaDocs to your IDE with the following URL:  https://hub.spigotmc.org/javadocs/spigot/

Build & Load the Mod

The template uses Maven as a build tool, your IDE will probably make everything nice and easy for you, but if you really need to download it see here.

Running the maven install command will generate a jar of the template mod in the target directory.

You can copy this jar file into the plugins directory of the Spigot server and run the reload command to have the server pickup new mods.

The template mod has a single command, and if you are a server admin you should be able to run this and see some output in the server console.

Depending on how old this post is when you are reading it you might need to update the dependency version in the pom.xml using newer versions from https://hub.spigotmc.org/nexus/content/repositories/public/org/bukkit/bukkit/ or follow some slightly different instructions in the README for the mod template.

Changing the Mod

Obviously you will want to have a mod that includes more than just a single command, and after my entire journey, I concluded that “bukkit” is the wrong thing to search for when looking for resources. Instead, look for “Spigot”.

The single page Bukkit plugin tutorial certainly helped me, but the Spigot Wiki is absolutely packed with resources including some of the below:

My first mod

I created a silly little mod that moves from blocks around, you can find it on Github. If you want the specific version that I created while writing this blog post you can find that here (used to create the image at the top).

The majority of the code is held within a single Listener (less than 100 lines) which moves a block around for every block a player appears to move over. This can result in ores, diamonds and lava being brought up from the depths, but also your anything useful around you such as trees, chests or ore disappearing.

It needs a lot of refinement but was a fun test, and I look forward to working on it more. I also hope my couple of hours of investment can server some others well that want to dabble in the world of Minecraft Mods.