Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this article
Mojang provides a number of open-source scripting libraries, which allow you to see all of the changes and behind-the-scenes code. Some libraries can be used in your Minecraft projects, while others are helper tools and build scripts. Additionally, since the libraries are open-source you can contribute fixes and even submit your own libraries! For more information, please be sure to look at our Contributing Guide. Now that you're familiar with the concept, let's take a look at the libraries:
The math library contains a set of utility functions and a wrapper class for common Vector operations. Two patterns are supported; a more computational approach operating on the Vector3 interface with no mutation, and a separate wrapper object-oriented approach following a "builder" pattern. The choice of pattern is based on your preference; behind the scenes, the same helpers are used.
The core build tasks library contains common build tasks used in the minecraft-scripting-libraries build, but can be used in other repositories as well. If a task is used by the 'just' build infrastructure in multiple packages, it is moved into this package to reduce duplication.
Note
This subdirectory only runs the 'build' step - specifically, 'tsc' - since this package itself defines build tasks and must be kept lightweight.
The linting library contains best practices for authoring Minecraft script. Rules may include suggestions, such as "Use this API instead of this command!", or errors against anti-patterns to avoid pitfalls.
To author a new rule, add a file under 'src/rules' named after the rule. Rules are authored via the 'ESLintUtils' rule creator; more information on rule creation can be found here.
Once you have a new rule, update 'src/index.ts' and add it to the exported 'rules' key in the module exports and update the default 'eslint' configuration as to whether the new rule is an error or a warning.