GitHub

purplesyringa

I tried out Minecraft modding

This is a very different topic from what I normally do, I know! But there are so many things in the modding scene that I was surprised about due to my background that I had to write about it. If anyone is following me due to the posts on performance, low-level coding, and algorithms, I think you might appreciate the change in perspective I approach this from.

Overview

Modding a retro game typically means disassembling C code, writing patches in assembly, and a lot of time spent researching and debugging. If you get lucky and the game is more modern and written in C#, some of those steps will be easier, but it’s still a nightmare that doesn’t scale.

Minecraft is, by modern standards, just as much of a retro game, but the Minecraft modding scene looks completely different from the inside. Despite being a corporate asset, the game’s code is effectively source-available: good Java decompilers exist, class and method names are not obfuscated, and thanks to the nature of the JVM the decompiled code barely has any optimizations applied compared to the source.

The community has even come together and made mcsrc.dev, an online IDE that runs a Java decompiler right in your browser, shows you the decompiled code, and offers some LSP capabilities. You know how, say, you want to read the source code of Docker and open github.com? Or you want to check something in Linux and open elixir.bootlin.com? mcsrc.dev is exactly the same thing for Minecraft.

Official support

The Minecraft core itself is designed for extension. Most “user-facing” parts of the code are designed way better than what you’d expect from gamedev. It’s essentially enterprise code: there even are abstract factory factory factories, though they’re surprisingly pleasant to work with.

Minecraft supports some modding facilities out of the box. With each version, more and more stuff becomes “data-driven”, which means loaded from JSON files instead of being hard-coded into the Java code.

But I think the most surprising part for me, even if not technically impressive, is that all IDs are namespaced. There is no cobblestone block, only minecraft:cobblestone. The vanilla game uses only the minecraft namespace, they had literally no reason to introduce namespaces except to provide an official solution to name collisions in mods, but they cared enough about the modding scene to do it. In fact, even the word “vanilla”, meaning “an unmodded game”, is present in the code!

Modding itself

Remember how I said that modding Minecraft is way easier than writing patches in assembly? Well, what does modding involve instead then? There are two answers.

First, you can write mods using abstractions directly provided by a mod loader. I use the NeoForge mod loader; here’s how it works:

  1. When you launch the game for the first time, NeoForge decompiles some class files of Minecraft right on your computer, applies source-level patches to them, and compiles them back. This step allows NeoForge to hook into the core parts of the game. (The decompile-recompile process is necessary because the Minecraft EULA prohibits distributing the game files.)

  2. NeoForge uses those hooks to power its own event-driven API. For example, in the Minecraft block breaking method, it might insert something like NeoForge.ON_BLOCK_BROKEN_EVENT.deliver(coordinates, player), and then mods subscribed to that event will get a chance to run their logic. The same approach is used for registration: when, during early load, the game proceeds to the step where it initializes all block behaviors, NeoForge calls a NeoForge.ON_REGISTER_BLOCKS.deliver(registry) event, giving mods a chance to add their own blocks. So “event” doesn’t mean an in-game event specifically, but rather any specific hook point.

  3. Each mod is a JAR file, where the main class registers the event handlers. The class constructor sets up mod-specific state, early handlers register custom items and blocks, and late handlers react to world changes.

Thanks to this abstraction, you don’t need to know JVM assembly to write a mod. In fact, you barely need to know the Minecraft code. There is a lot of documentation, and while yes, I sometimes end up following references in LSP, it’s nothing that I don’t have to do in other projects.

As long as you stay within the boundaries of this approach, modding is no different from an enterprise project; you may even find some familiar abstractions.

Mixins

This suffices for almost every scenario, except when you want to add a game mechanic or hook into a location that the mod loader didn’t create an event for.

Enter mixins.

Put simply, mixins offer a way to rewrite the code in existing Java classes without going down to assembly level. Here is a simple mixin:

@Mixin(TrainCollisionPacket.class)
public abstract class TrainCollisionPacketMixin {
    @Inject(method = "handle", at = @At("HEAD"))
    private void handle(ServerPlayer player, CallbackInfo ci) {
        BasicAdvancement.SURVIVE_TRAIN_COLLISION.award(player);
    }
}

This says: insert custom code at the beginning of the method called handle in the class TrainCollisionPacket. There are also ways to redirect function calls to a different location, wrap calculations, capture field accesses, etc.

Back when I started modding, I thought mixins were simply a way to enable “assembly-level” patches while staying in Java land. But then I talked to the Mixin developers and realized that mixins offer much, much more.

Mixins offer a composable way to perform assembly-level patches.

In the early days of Minecraft modding, before Mixin existed, people patched existing classes by manipulating assembly. If two different mods wanted to manipulate the same class, things got nasty. Maybe one mod would hard-code the index of an instruction, and another one would shift it. Maybe one mod would inject at each call of f(), and another mod added another a call to f() that the first mod didn’t account for. Maybe the JVM verifier didn’t like the combined bytecode. You get the idea.

Mixin became a framework that was solely responsible for writing assembly, and thus could ensure that the intended high-level semantics of all patches are realized simultaneously.

You have to respect the engineering behind the modding framework. It looks deceivingly simple, but only because so much effort was put into making it stable.

Ergonomics

A large part of modding is writing mixins. So you get your hands dirty and write Ljava/util/List;add(Ljava/lang/Object;)V, run ./gradlew build, pray that it doesn’t crash in runtime, and when it inevitably does three minutes later, remember that the V should’ve been a Z. Rinse and repeat.

…is how the story goes if you don’t use IntelliJ IDEA. The only tools we have that let you write mixins like it’s 2026 are all made for that IDE. There is no language server, no free software alternative, no external static checker or tool. The reliance on bulky corporate software is insane to me, but apparently that’s just how things are here??

Dev style

I’m used to projects that require a lot of preparation before writing code. But modding feels like being a kid again and writing frontend in pure JS. What do you mean I can just write a couple mixins and get a cool mechanic done in a day?!

Of course, this didn’t last for too long: as I got familiar with the codebase and started yearning for complex features, the design stage became more prominent. But it’s not necessary, even to make something unique.

Admittedly, some of the differences in approach come from what counts as “working”. Minecraft is a buggy game, and many odd glitches are treated as cool game mechanics by the player base. Hell, half of redstone is built on bug abuse. So if something mostly works, but not quite as intended, that’s not a big deal – after all, you’re the only person who knows what’s intended. And since the community is full of modders not briefed on software reliability, it’s not like making your mod perfectly reliable is worthwhile, when ten other mods that everyone uses are more buggy.

LLMs

It’s weird. The community is largely split. Some mods embrace full vibecoding, others like Create adopted a no-AI-at-all policy. One mod repository requires an AI disclosure and removes fully vibecoded mods, another one has no qualms about them. Opinions on different subreddits vary.

One constant seems to be the idea that AI is “just a tool” and there’s no big deal as long as it’s used “responsibly”. This feels like astroturfing, and the talking points are always essentially identical, including the wording. Frankly speaking, both possibliites make me uncomfortable: either someone is investing disproportionate money into manipulating gamer’s opinions again, or someone has enough free time and not enough critical thinking to believe that saying “everyone not using AI will be left behind” is a good argument to post on every thread about ethics.

The good news is that it doesn’t seem like vibecoding isn’t going to affect large mods too much. Most popular mods that use LLMs only use them for porting, complete slop doesn’t get updated and is quickly forgotten, and the overall reception is lackluster at best, so it’s probably not going to become that big of a problem.

I’ve noticed that modding has affected the way I view LLMs, though. So much of what I typically work on involves more thinking than doing. But with modding, there are places where boilerplate can’t be removed upstream, but a specialized framework would be too unusual for contributors. Couple that with Java being a verbose language and Minecraft refactoring internals with each version, and I can see why it’s tempting to let an LLM deal with that.

Mostly I feel uncertain about this. Of course there are things that I wouldn’t trust an LLM to do, but it’s concerning that, at least in some areas, my actions are dictated exclusively by my values and indirect consequences, not anything objective. Oh well.

Community

The people are nice. There are some trolls, but the modders are mostly cool.

But omg, Discord. Let’s say I want to ask a mod owner for clarification on the license, or a question about the internals of their code. I join their Discord and it asks for me to confirm my telephone number (no, that’s not a scam, that’s a built-in Discord feature). I leave their Discord.

I find another mod. After accepting their Discord rules full of gems like “arguing with the mod team is forbidden”, I need to wait for 10 minutes before writing a message.

The only thing worse than mods that primarily use Discord are mods that use GitHub. Say I spent the last two hours minimizing a bug, got it down to three mods, and spent an hour reading their source code until I found the root of the problem. There are three lines of code that need to be written differently, but I’m not quite sure how, so I can’t open a PR. The issue template asks me for:

I’m tired after three hours of debugging, and now I need to start the instance again, verify that there’s no private info in the log, manually retype versions from three different locations, and then write reproduction steps and my code analysis.

I understand why people do this, otherwise their issue trackers just get polluted with unformatted copy-pasted crash logs. But the end result is that more often than not, I just don’t report the bug and fix it on my side with a mixin.

I wish more people used email.

Releases

I’ve been doing this for a couple months now, but I still don’t have much to show for it.

The problem is that making a cool mod is not very useful goal. I want a good gaming experience. I want a progression, a goal, I want to integrate with the base game and other mods, and give people a reason to play a game and not just play around with the mod. So currently I’m learning game design. We’ll see how it goes, for now I’m just enjoying building something together with friends.