[TUTORIAL] How to develop Plugins #1 - Setup

Started by SparkleArts on

Topic category: User side tutorials

Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] How to develop Plugins #1 - Setup
Sun, 04/30/2023 - 18:46 (edited)

Before we start:

This is a tutorial series I'm starting with. To help you keep track of which tutorials will be available for each tutorial, I will include a table of contents at the beginning of each tutorial.

Table of Contents:

Color Meanings:
  • Bold = You're here 

  • Red = Coming Soon

  • Grey = Planned


  1. How to develop Plugins #1 - Setup
  2. How to develop Plugins #2 - Translations

  3. How to develop Plugins #3 - Templates

  4. How to develop Plugins #4 - Procedure Blocks

  5. How to develop Plugins #5 - Toolbox

  6. How to develop Plugins #6 - Global Triggers

  7. How to develop Plugins #7 - Themes

  8. How to develop Plugins #8 - AI Tasks

  9. How to develop Plugins #9 - Mod Elements

What you can make:

With MCreator Plugins you can add new Features to MCreator:

  • Custom Procedure Blocks
  • Custom Global Triggers
  • Custom JSON Advancement Triggers and Categories
  • AI Task Blocks and Categories
  • New Generators
  • New Variable Types
  • New UI themes
  • New languages
  • Mod Elements (Java Plugins)

Also to note that there will be no Tutorial for Mod Elements as I'm not familiar with. Because these are more complicated then the Other Features. I'm planning to make a Tutorial in the Future.

What you need:

Before we can start the Tutorial we need some Softwares!

  • Text Editor:
    • You could use the basic Text Editor but I recommend to use a professional Text Editor with Syntax Highlighting and Code Suggestions. Text Editor you can use is Notepad++, Visual Studio Code, Atom or Sublime Text. I prefer using Visual Studio Code.
  • Java Language/Experience:
    • You need to understand a little bit of Java because if you want to add Procedure Blocks and Global Triggers you need to use Java Code to make them work.

Basics:

First of you need to create a Basic Plugin Structure of Folders:

Don't remind the ForgePlus.zip File this is the Plugin in the final Form. Let's take a look of all the Folders and what they mean:

  • plugin.json (Mandatory): All Plugins should have this File - This File contains Informations such as Author, Description, Min Version, Max Version, Plugin ID etc.
  • "procedures" Directory: In this Folder contains all the Blockly JSON Data for each Procedure and Category. We take a better look how they work in a later Tutorial. This contains only the Formats and the Visuals of a Procedure Block, not the actual Code.
  • "triggers" Directory: In this Folder contains all the Blockly JSON Data for each Global Trigger. This contains only the Formats and the Visuals of a Global Trigger, not the actual Code.
  • "aitasks" Directoy (not Shown in the Image): In this Folder contains all the Blockly JSON Data for each AI Task. This contains only the Formats and the Visuals of a AI Task, not the actual Code.
  • "lang" Directory: In this Folder contains all the Properties Files for each Language. We take a better look how they work in the next Tutorial.
  • "forge-x.xx.x" Directories: In this Folder contains all the Files to generate the actual Code(AI Tasks, Global Triggers, Procedure Blocks etc.). Replace the "x.xx.x" with the Minecraft Version you want to add the actual Code. At the writing of this Tutorial the Supported Minecraft versions is 1.18.2 and 1.19.2.

plugin.json Explanation:

The "plugin.json" is the most important File of your Plugin. Without it you cannot use the Plugin in the final Form and MCreator cannot read all the necessary Data it needs. 

Let's take a look on a existin "plugin.json" file from a Plugin I develop:

Let's look at the data line by line.

id (Mandatory): This is the ID of your Plugin. Every Plugin should have a ID. Try to make the ID unique to avoid Conflicts with other Plugins. You should use English characters and it cannot have capital letters. Please also avoid using special symbols and spaces.

minversion (Suggested): The minimum MCreator version your plugin works on, used to ensure compatibility with the version of MCreator your user is on. Specific to the build number. Exact build numbers can be found at https://mcreator.net/changelog, but do not include the dots and add a extra zero in after the year number. For example, if the build number at https://mcreator.net/changelog is 2020.3.22116, the number you write here is 20200322116.

maxversion (Not shown here, Suggested): The maximum MCreator version your plugin works on, used to ensure compatibility with the version of MCreator your user is on. Specific to the build number. Exact build numbers can be found at https://mcreator.net/changelog, but do not include the dots and add a extra zero in after the year number. For example, if the build number at https://mcreator.net/changelog is 2020.3.22116, the number you write here is 20200322116.

weight: You can see this as a Sort Order.

The info Block (Mandatory):

  • name (Mandatory): Displays the name of the Plugin. Try to avoid long names and names with Non-English characters to prevent rendering problems.
  • version: Displays the current Version of your Plugin.  Try to avoid long version names and version names with Non-English characters to prevent rendering problems.
  • authors (Mandatory): Displays the Author Name(s) of your Plugin.  Try to avoid long names and names with Non-English characters to prevent rendering problem.
  • description: Adds a Description to your Plugin. Try to avoid descriptions with Non-English characters to prevent rendering problem.
  • credits: Credits of your Plugin (e.g. Contributors).
  • dependencies (not shown here):  A list of plugin dependencies the plugin needs to work properly. This list uses the IDs of the plugins. If a plugin listed here is missing or is not loaded by MCreator, the plugin will also not be loaded.

Exporting:

Now we talk about the ForgePlus.zip file I mentioned earlier. You need to export your Plugin by selecting all the Folders and Files when you see the Basic Folder Structure of the Plugin. It should have this Structure inside the ZIP File:

  • <plugin file name>.zip
    • plugin.json
    • (procedures)
    • (<generator 1 name>)
    • ...

Javadoc:

The Javadoc is useful if you wanna create a Java Plugin.

You can find the Javadoc of MCreator here.

Edited by SparkleArts on Sun, 04/30/2023 - 18:46