Last week I updated Bok’s Banging Butterflies to use Forge’s native data generation code. At first it all seemed to be going well. But this week I started porting the code to other versions and I’m starting to hit walls. Turns out, this is going to be more difficult to maintain than I thought.
Build Data Action
One of the first things I wanted to try was to use Github Actions to generate the data when it creates a release. The idea would be that I would never need to check in generated files, and would be able to avoid all those niggling conflicts I get when merging changes from one branch to the next.
To do this, I added /src/generated/ to my .gitignore file, and deleted all the files that were currently in the repo. I then added a step to build the date before compiling the java code to my workflow YAML files:
- name: Build Data
run: ./gradlew runData
I wasn’t sure if this would work, so I just had to push the change and let the scripts do their thing. Once it had published a new version to CurseForge, and after it was approved, I downloaded and launched the game locally. It worked perfectly first time, something you never expect as a seasoned programmer.
This meant that I could now remove over 700 files from my repository, reducing the number of conflicts I have to deal with whenever I port my code. The unfortunate part is that getting past this initial port didn’t go as well as this first step.
Losing Features
As I started porting the game to earlier versions, I noticed how quickly the data generation would lose features. As I backported I found myself having to restore some data files and some of the Python code in order to do data generation. A major example is in the 1.18.2 version, which doesn’t support generating advancements.
Still, at least I already had the code ready to go. I just needed to ensure that everything still worked before pushing out a release. This part was difficult, but it was nothing compared to how difficult it was moving forwards instead.
Documentation Needed
You may notice if you are reading this just as I release the article that there is still no 1.21.4 version released yet. This is because the data generation code has undergone a significant rewrite, and its taking me some time to figure out exactly how to implement the data generators with the new code.
A major part of the problem is the distinct lack of documentation. This is a problem that plagues Minecraft mod development. I am often able to figure things out by looking up the primers, or searching open source projects, or even just asking on NeoForge’s extremely helpful Discord. But sometimes the documentation just isn’t there at all.
Of course, I don’t want to sound like I’m insulting the NeoForge devs. They do hard work enabling modders to do their thing, and I’d be remiss to ask more of them. It’s just that sometimes their limited time and resources leads to large gaps in the documentation that can slow other modders down.
I think I’m close to figuring out the new system, so I should have a 1.21.4 release out soon. I like to at least try and have some code written before I go to the Discord for help. It’s easier for them to point out what I’ve done wrong than to explain everything from scratch.
Bugs Fixed
I said last week I didn’t do a release because there were no new features worth releasing. This week a release is worth it, since I’ve fixed a couple of bugs! Namely:
- Breaking a Bottled Light Butterfly in later versions would give the player a Bottled Peacemaker Butterfly instead.
- Placing a Bottled Peacemaker Butterfly would create the hostile mod instead of the trapped docile mob.
Both of these bugs have now been fixed, so you can enjoy interacting with both Light and Peacemaker Butterflies as originally intended!
As always, if you find a bug or have any suggestions for the mod, feel free to open a ticket.