Giving Support to Modpacks

An interesting bug report I received recently involved a compatibility issue with another mod. There wasn’t anything inherently wrong with my code, but it does highlight something important in the modding community. We need to support each other so that people can enjoy playing modded Minecraft any way they desire.

This week I got a bug report about an interaction my mod has with another mod. The player was attempting to use the Empty Pollen Jar from Flowerary to collect pollen, but instead of getting Flower Seeds, the flowers were being converted into the Flower Buds from Bok’s Banging Butterflies.

So I did the obvious test first. I launched CurseForge and created a quick mod pack with only these two mods in it. When I ran the game and tried to collect pollen, everything worked as it should. There was no bug to be found. This told me that it was likely that Flowerary wasn’t causing this bug. It had to be another mod.

So, just to confirm I installed the Jinxweed Cottagecore Lite modpack, since that was where this bug had been spotted. After playing around with some memory issues I managed to load into a creative world and tested the Empty Pollen Jars again. Sure enough, the bug happened. But more importantly, I noticed that I didn’t need to have an item in hand, just right-clicking any flower would cause flowers to turn into flower buds.

With this, I knew that another mod was causing this bug. It was most likely a mod that adds a right-click harvest, but after going through the list of mods in the pack I couldn’t find any mods that added this feature. I ended up emailing the pack’s creator, and they got back to me fairly quickly. The mod I was looking for was called Quark.

I did another test and confirmed that it was Quark’s Simple Harvest Module that caused the bug. I told the user that a workaround would be to switch this feature off, since the mod provides a handy options screen to allow players to customise the features they want to use.

But, that is a workaround, not a fix. I wanted players to be able to use the features from both our mods. Quark is open source as well so I was able to look through the source code for this feature. It’s a pretty smart implementation that allows it to support many mods, but I could also see how it mistakenly thought Flower Buds behaved like other crops. Thankfully, there was one line of code that stood out to me:

		simpleHarvestBlacklistedTag = Quark.asTagKey(Registries.BLOCK,"simple_harvest_blacklisted");

Vazkii, the developer of Quark, had already accounted for mods needing to blacklist certain crops from this feature. They can add a tag that adds to this blacklist, and the feature will be disabled for those specific crops. All I needed to do was to add a tag to my own mod that would add flowers to this blacklist. Of course, I can use data generation to do this:

public class ModBlockTagsProvider extends BlockTagsProvider {

    private static final TagKey<Block> SIMPLE_HARVEST_BLACKLISTED =
            TagKey.create(Registries.BLOCK, new ResourceLocation("quark", "simple_harvest_blacklisted"));

    /**
     * Construction.
     * @param packOutput The pack to output to.
     * @param lookupProvider Helps with registry lookups.
     * @param existingFileHelper Helps to check existing files.
     */
    public ModBlockTagsProvider(PackOutput packOutput,
                                CompletableFuture<HolderLookup.Provider> lookupProvider,
                                @Nullable ExistingFileHelper existingFileHelper) {
        super(packOutput, lookupProvider, ButterfliesMod.MOD_ID, existingFileHelper);
    }

    /**
     * Entry point.
     * @param lookupProvider Helps with registry lookups.
     */
    @Override
    protected void addTags(HolderLookup.@NotNull Provider lookupProvider) {
        tag(SIMPLE_HARVEST_BLACKLISTED)
                .replace(false)
                .add(TagEntry.tag(new ResourceLocation("minecraft:small_flowers")));
    }
}

I built a new version of the mod and tested it with Quark installed, making sure I had the Simple Harvest feature enabled. The fix worked, and I pushed out a new release so players could benefit as well. Now Bok’s Banging Butterflies can be used with the amazing Quark mod with at least one less bug.

When you have hundreds of people all adding new features and ideas to a game without talking to each other conflicts are inevitable. But it’s still worth putting in a bit of effort to make your mods compatible with others, as it allows more mod pack creators to use your mod.

This week I added a fix that allowed players to use someone else’s mod with mine. Vaskii, however, had already thought ahead and implemented something other modders could use to fix my issue already. I didn’t need to talk to them, or ask them to make any changes to their mod, all I needed was a quick glance at their code and I could see the simple fix they had already laid out for modders like myself.

That is the other advantage of ensuring mod compatibility. If you plan ahead well enough, you may be fixing bugs that don’t even exist yet!

And as a small addendum: both of the mods I mentioned in this article are worth checking out. I may do a review of them one day, but my short review is: I like them.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.