Skip to content

Naming Conventions & Recommendations

Mqx edited this page Feb 20, 2025 · 5 revisions

Documentation

The documentation format is recommended for maintaining well-documented functions.

Files

Name

The name of function files and folders should only contain the following characters: a-z, 0-9, _ and ..

Note

The reason for this is that different operating systems treat file and folder names differently due to casing or certain special characters. The restriction to this set of characters ensures that files and folders are treated the same on all operating systems and that it is universally readable.

Globally predefined function file names:

  • load.mcfunction This function is called at every start
  • tick.mcfunction This function is called every tick

Structure

Function files and folders should be written in snake_case. Numbers within the function or folder name should not be used for numbering or to enforce a certain structure.

Organize your files into "modules". Modules are folders which contain either/or a tick.mcfunction and load.mcfunction function file. The tick.mcfunction function file serves as the "entry point" for the module and the load.mcfunction function file serves as the "setup".

Note

The "modules" ensure a clear global structure for the entire project. This makes it easier for other developers to understand the source code and further work on it.

Content

Uninstall or Removal

Your datapack should always provide a <namespace>:uninstall function for the user.

Datapack/
├─ pack.mcmeta
└─ data/
   └─ <namespace>/
      └─ function/
         └─ uninstall.mcfunction
  • <namespace>:uninstall This function is responsible for calling all the remove functions to leave no artifacts of the datapack behind. This function should also disable the datapack after calling all remove functions.

Note

In the real world, almost every program provides an uninstall file in addition to the installation file. So datapacks should also always provide an uninstall function.

...

...

External Libraries

External libraries or libraries in general should follow this structure:

Clone this wiki locally