Jaffle Minecraft modding platform

I’ve finally got my modding platform for command mods in MC working. It’s now available on github as a download.  I have released it under the MIT License so be sure to copy the copyright information and license if you use any part of the code in your own project. If you put your own project in a separate datapack, you won’t need to include any of the original license information in it.

How it works

The basic concept is pretty simple. Jaffle creates an armor stand with a scoreboard variable that increments every clock tick and resets every second. A specific function in each mod is called within each clock tick in a one second period. A function in each mod is also called every single clock tick. This allows mods to execute every second or every clock tick and also reduces performance penalty by spreading the processing load across a one second interval.

To clarify the terminology used for Jaffle, a ‘mod’ can refer to either a set of functions in a single namespace, ie a module, or it can refer to the conceptual mod composed of functions which change the way MC works. Normally all the function files for a single mod will be kept in the same functions folder within the namespace for that mod.

Jaffle can be configured with all the mods in the same datapack as Jaffle itself, however if you put the mods in a separate datapack it means you won’t need the original license file in your datapack.

The platform uses ‘glue’ modules which have their own namespace. These are named jaf_modX, where X is the mod number. The platform currently allows up to 10, but you can probably figure out how to change Jaffle to allow even more mods.

The glue modules then call the relevant functions in your own modules. That way the original Jaffle functions don’t need to be changed. The developer just needs to add their own glue module and mod functions. You can mix and match different mods together. It’s also ok to change the mod number in the glue module for compatibility.

A module called jaf_pack contains a couple of functions used by Jaffle to display an introduction to the mod pack when the pack is first started up in the MC world. These functions should be updated by the developer.

There are a couple of example modules included with Jaffle: joa_fx and joa_pim. joa_fx just provides an effect that causes any entity with the JOA_FX_Num scoreboard variable set to 1 to spin around, give off colorful particles and rise up in the air for a couple of seconds. joa_pim protects valuable items by preventing them from despawning and making them invulnerable to damage. It also stops items from falling into the void.

These modules show how Jaffle can be used to simplify command mod development in MC.

There is a python script, manual_parser.py, in the Jaffle datapack folder (called jaffle-master in the direct download). This can be used to generate a release version of the mod pack (more on this in a later post) or can be used to check if there are repeated tags or scoreboard variables between modules. The developer needs to maintain a list of their scoreboard variables and tags to make use of this, hence the name ‘manual’_parser. I’m working on an automatic parser that will one day automatically identify tags and scoreboard variables, even when inside quotes.

How To Use it

Due to the way Github works, the downloaded zip file can’t be placed directly in the datapacks folder of the world. Instead, extract the jaffle-master folder and place that folder in the datapacks folder.

Be aware that this folder will disappear if your MC world is deleted, therefore I strongly recommend backing up your design to a more permanent location. Github is a good idea if you understand or can learn how to use Git and don’t mind paying the monthly fee or having your backup publicly visible. It allows copies to very quickly be dropped into your MC worlds.

To create a new mod pack, just replace the contents of the files in the jaf_pack namespace to display the information you wish to be displayed.

To create a new mod, create your own namespace and put your files in them, keeping in mind that some will be called just once, others once per second and others every clock tick.

create the jaf_modX namespace, replacing X with the next available single digit number. Jaffle will try to call specific functions within this namespace. These include setup, tick0 … tick19, everytick and intro. These files should call the relevant files in your mod. You could just put your code in there, but then your mod wouldn’t have its own namespace.

Use the example modules in the Jaffle download to understand how the mod platform should be configured.