Creating a new MCreator generator

Works with

If you want to see a generator example, you can check the Fabric Generator GitHub page here or go inside the MCreator folder/plugins. However, you can’t redistribute the official generators.

Some information before starting

Before starting, you need to know that this is the most complicated and difficult part of the plugin system. So, if you don’t understand the plugin system, don’t know MCreator, or don’t know how (and where) MCreator save the files, learn them before. I can’t explain everything on the generator system because it would be too long and you won’t learn something. You will only copy and paste the page.

Also, depending on the type of generator you want to make, you will need to adapt this guide for your usage. Finally, all of the files and folders you have to create have to bee in the main folder (Not the folder with the plugin.json. The folder after the plugin.json). Let’s start now!

Setting up the generator (generator.yaml)

The generator.yaml is the file used to set the pieces of information about the generator. This file can be very short or very long depending. For this tutorial, I will explain to you the code with the generator.yaml of Forge 1.14.4.

Setting up the generator selection window

name: Minecraft Forge for 1.15.2(@buildfileversion)
basefeatures: [global_variables, model_json, model_obj, model_java, link sounds]
partial_support: [item, textures]
status: deprecated
buildfileversion: 32.2.0

In this first part, you can see many things. The first thing you can see is the name. This name will be the name displayed in the generator selection window. As you can see, there is a @minecraft and @buildfileversion. @minecraft will take the version you will write after. @buildversion is the same thing but with the build version.

The second line is the base features supported by your generator. I think I don’t have to explain what they mean except for ”link” who is for Minecraft Link. You have all of the base features supported by MCreator wrote.

Partial_support is used to say they don’t fully support. It will put a yellow ”!” to the element written.

Then, you have the status of your generator. You can only write ”Deprecated”, ”lts” for ”Long Term Support”, and ”dev” for ”In Development”. If you write something else, MCreator won’t load your plugin and won’t open.

Finally, ”buildfileversion” is the version of the build file you used. For example, if you make a new Forge Generator, you will put the Forge version, and a Data pack generator will have 1.0.

Setting up Gradle

# gradle task definitions
gradle:
  setup_task: eclipse
  run_client: runClient
  run_server: runServer
  export_file: "build/libs/modid-1.0.jar"

We have now set up the Gradle. To disable the environment test (like for the Data Packs) remove the ”setup_task”, ”run_Clien” and ”run_Server” lines. There are some other files to change, but we will see them later. The last line is export_file. This file is an auto-generated file created by MCreator, and when the user will export his modification, it will generate this file. The Data pack file is in ”build/export/export.zip”. You don’t need to change the name before the extension because MCreator will change it with the name file written by the user.

Setting up the roots

We enter now in the complicated part if you want to change the folder configuration.

# base generator roots
source_root: "@WORKSPACEROOT/src/main/java"
res_root: "@WORKSPACEROOT/src/main/resources"
mod_assets_root: "@RESROOT/assets/@modid"
mod_data_root: "@RESROOT/data/@modid"

# specific resource folders
structures_dir: "@MODDATAROOT/structures"
sounds_dir: "@MODASSETSROOT/sounds"
other_textures_dir: "@MODASSETSROOT/textures"
block_textures_dir: "@MODASSETSROOT/textures/blocks"
item_textures_dir: "@MODASSETSROOT/textures/items"
armor_textures_dir: "@MODASSETSROOT/textures/models/armor"
  • ”source_root” is the path of the .java files.
  • ”res_root” is the path for ALL resources of the mod/data pack. It contains textures, sounds, translation files, structures, custom models, etc.
  • “mod_assets_root” is the path for all asset files. It contains files like textures, models, and sounds.
  • ”mod_data_root” will be the path of all data files like the structures and the tags.

You can delete the ”mod_data_root” and the ”mod_assets_root” without problems. However, if you delete the ”source_root” and the ”res_root” (in some case only for it), MCreator won’t be able to export the .jar or the .zip file. It will do nothing in the Console.

You have surely seen @WORKSPACEROOT and @RESROOT. If you have read correctly you will surely know what they mean. People who didn’t know, they are used to take the path of the workspace and the path of the resources. You may ask yourself  ”Where is the path for the workspace?” I will answer you we can’t access it and change it because it is in the MCreator side part. We will also use, later, @SRCROOT for the source root and @MODASSETSROOT for the assets.

Setting up made base templates

For this part, I won’t put everything on the Forge generator because there are too many things. If you want to have all of them, I suggest you to go check into the generator-1.14.4 in the MCreator plugin folder (< install dir>/plugins).

base_templates:
  - template: modbase/modelements.java.ftl
    name: "@SRCROOT/@BASEPACKAGEPATH/@JavaModNameElements.java"
  - template: modbase/mod.java.ftl
    name: "@SRCROOT/@BASEPACKAGEPATH/@JavaModName.java"
    canLock: true

The ”template” lines are used to say where are these files into the plugin. They will be always into the Templates folder (we will speak of this folder later).

”name” is the location of the file(s) when it will be created. So for the first, it will get the source root. Then, the package is given by the user, and finally, it will create the file with the name of the mod + Elements (for example WikiModElements.java). The ”canLock: true” says if the file can be locked or not (true = can be locked, false = can’t be locked).

Setting up the language files

language_file:
  format: json
  root_folder: "@MODASSETSROOT/lang/"
  langfile_name: "@langname.json"

”format” is the file extension. You shouldn’t need to change it. The root folder is the root where lang files will be saved. Finally, ”langfile_name” is the name who will be given to the files. @langname will get the name of the file (for example en_us, fr_fr, de_de, etc).

Setting up the resource tasks

For this part, I won’t put everything on the Forge generator because there are too many things. If you want to have all of them, I suggest you to go check into the generator-1.14.4 in the MCreator plugin folder (< install dir>/plugins).

resources_setup_tasks:
  - task: copy_file
    from: "@MODASSETSROOT/textures/@modpicture.png"
    to: "@MODASSETSROOT/icon.png"
  - task: copy_models
    type: OBJ
    to: "@MODASSETSROOT/models/item"
  - task: copy_models
    type: JSON_noinlinetextures
    to: "@MODASSETSROOT/models/custom"

As you can see, there are three different tasks, the ”sync_dir”, the ”copy_file” and the ”copy_models”.  The ”sync_dir” is the most used because you have to use it for all textures, sounds, and structures. The ”copy_file”, with Mods, is only used to copy the mod logo. Finally, there are the ”copy_models” used for custom block and item models (OBJ and JSON files).

When you have finished setting up everything your generator needs, you can export it and test it in MCreator. If it loads correctly and you can see your generator when you create a new workspace, you have finished the first step! Well done! The most complicated is passed. Let’s continue!

Workspace Base folder

To do this part, I suggest you copy the workspace base folder of one of the MCreator plugin. If you need the Environment Test, take the Forge folder, and if you don’t need it, take the Data pack folder. The folder has only to go inside the main folder (same folder of the generator.yaml). However, depending on the generator you want to make, you will have to change the Gradle Wrapper (workspacebase/gradle/wrapper).

Mod Base Folder

This folder is in the ”Templates” folder of the Forge generators.

Pack.mcmeta.ftl

This file is the pack.mcmeta used for the resource packs. If you don’t have any resources (textures, sounds, models, lang files), you don’t need to take it. If you need it, take it and change it if needed.

Other files

If you want custom sounds in your generator, take the sounds.json.ftl and modify it if necessary. ”variableslist.java.ftl” is about the Global Variables. Modify it if necessary. Take and modify the other files if you make a mod generator. The ”mod.toml.FTL” file Is the file with the Workspace settings.

Making the mod elements

Definition files

Definition files are here to say where is the Template code file if the element (template: ) and where MCreator has to save the files (name: ). The localization keys are used to replace specific language text (almost only the name) by something of general. These localization keys are into the lang files to set text in different languages with different words.

Template files

These files are into the ”Templates” folder. It is with these files that MCreator generates the code for each element. Modify the code for your generator and be sure, to don’t re-use the code to be in right with the MCreator’s license. 

Others files

If you make a generator for another version, be sure to adapt the code for all other files into the generator (I suggest you check one of the two Forge generators, and copy, paste, and modify the code.). Don’t forget also to change the mapping files.

When it’s finished, export your plugin to a .zip file, import it inside MCreator and test it! Try to find bugs, fix them, and publish it!



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.