A Gradle plugin for generating multi-version NMS accessors.
- Mappings generated by this library can be browsed here.
These mappings are provided "AS-IS", with no warranty, so mistakes are possible. We are only solving issues in classes, that we are actively using in ScreamingSandals plugins.
If you want to fix anything, feel free to open a pull request or contact us on our Discord server.
NMSMapper is made for servers! Many client-side mappings are missing.
Usage of this Gradle plugin requires significant knowledge of Java Reflection!
This project requires Gradle >= 7.0. Maven is not supported. At least JDK 11 is needed for compiling, however the compiled classes use only Java 8 methods.
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Defining objects for generation¶
We want to access the
net.minecraft.core.Rotations class in our plugin. The following method generates a new class, named
RotationsAccessor, which you can use to retrieve the type.
1 2 3 4 5
1 2 3 4 5 6 7 8 9 10
getType(), which returns a class based on the version and platform (Spigot and Forge is supported).
Okay, we have a class. But classes are not all, we also need to access some fields, methods or even constructors.
1 2 3 4 5 6 7 8 9 10 11 12
This will generate access methods for one constructor, three fields and three methods.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
getField<Name>and will always return
Field. A generated access method for a constructor will always be called
getConstructor<Index>and will always return
Constructor<?>. This index is generated from the specified order in
A generated access method for a method will always be called
getMethod<Name><Index>and will always return
Method. Here the index is present, because multiple methods can have other parameters, but the same name.
If a class, a field, a method or a constructor is not found,
null is returned.
Maybe you are asking: How to define parameters to methods? It's actually pretty easy, and the same applies to constructors:
1 2 3 4 5 6 7 8 9
String.class, in groovy you don't have to specify the .class suffix), strings (
java.lang.String) or an another requested class (in this example it's Level).
Arrays of requested classes
You can create an array of a requested class by calling
.array() on it, useful for defining parameters of a NMS type.
You can also specify an another NMS class as a parameter without requesting it, in this case you will have to add a prefix:
1 2 3 4 5 6 7
Levelwill be generated anyways.
If the class is an enum and we want to retrieve its enum value, we can simply use the
1 2 3 4 5 6
getFieldmethod will be generated again, however it will return directly the
- For generating accessor classes, you will have to execute the
Using alternative mappings/custom versions¶
If you want to use alternative mappings or specific versions for generating accessors, prefix the build.gradle declaration with
<mappingtype>: and suffix it with
Available mapping types are
mojang, searge, spigot, obfuscated. Mojang mappings are used by default (if available).
Generating configurations for new versions¶
Versions lower than 1.9.4 are not supported and will not work!