FastNbt is ~190% faster than NBT API.
Check the benchmark here
FastNbt is easier to use compared to NBT API and requires less boilerplate code.
NItem nItem = new nItem(new ItemStack(Material.PLAYER_HEAD));
nItem.setSkull("dummy", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc4ZWYyZTRjZjJjNDFhMmQxNGJmZGU5Y2FmZjEwMjE5ZjViMWJmNWIzNWE0OWViNTFjNjQ2Nzg4MmNiNWYwIn19fQ==");
nItem.save(); // If finished editingNOTE: FastNBT supports only Compound strings. If you want to use legacy notation you have to call the Spigot API as usual.
NItem nItem = new nItem(new ItemStack(Material.STONE));
nItem.setDisplayNameCompound("{\"text\":\"Example Compound Name\",\"color\":\"blue\"}");
nItem.save(); // If finished editingnItem.setAttributeModifier(
"minecraft:generic.movement_speed",
1,
6,
"bro",
"mainhand",
1337,
1337
);
nItem.save(); // If finished editingNList attributes = nItem.getOrAddList("AttributeModifiers", NBTType.Compound);
NCompound attribute = new NCompound();
attribute.setString("AttributeName", attributeName);
attribute.setInt("Operation", operation);
attribute.setInt("UUIDLeast", uuidLeast);
attribute.setInt("UUIDMost", uuidMost);
attribute.setDouble("Amount", amount);
attribute.setString("Name", name);
attribute.setString("Slot", slot);
attributes.addCompound(attribute);Currently, supports only items.
This is the easiest way.
name: Your Plugin
author: You
# ....
libraries:
- beer.devs:FastNbt-jar:VERSION<dependency>
<groupId>beer.devs</groupId>
<artifactId>FastNbt-jar</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>dependencies {
compileOnly("beer.devs:FastNbt-jar:VERSION")
}This is the easiest way, but requires some special steps.
Shade libby into your JAR, read more here.
Add the lib into libraries-libby of your plugin.yml and specify the --remap flag.
name: Your Plugin
author: You
# ....
libraries-libby:
- beer.devs:FastNbt-jar:VERSION --remapYou need to include this LibsLoader class in your plugin and call in onLoad.
This will load the libraries you specified in the plugin.yml file.
new LibsLoader(this).loadAll();Same as Method 1
You can shade the library in your plugin if you want to use it without connecting to maven central.
<dependency>
<groupId>beer.devs</groupId>
<artifactId>FastNbt-jar</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>beer.devs.fastnbt.</pattern>
<shadedPattern>YOUR_PACKAGE_HERE.libs.beer.devs.fastnbt.</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>dependencies {
implementation("beer.devs:FastNbt-jar:VERSION")
}tasks {
shadowJar {
relocate("beer.devs.fastnbt", "YOUR_PACKAGE_HERE.libs.beer.devs.fastnbt")
}
}- Create a new module for the new NMS version and add the correct
paper-nmsdependency. - Add the new NMS version to the
Versionenum. - Add the new module in the modules list of
FastNbtmodule and as dependency in theFastNbt-jarmodule.
Should be all.
Deploy only the FastNbt-jar module, as it contains the library and the API.
mvn deploy -pl FastNbt-jar -DskipNexusStaging=true -Ppublish-to-maven-central
mvn install
- Clone it
- Make your changes
- Run
mvn installin order to access the plugin as dependency in your projects
In order to update Javadocs you have to build locally, as old NMS jars are not available and can't be easily included on Github.
- Run the command
mvn clean install javadoc:javadoc -pl FastNbt-core -am - Get the generated javadocs from
.cache/targets/FastNbt-core/target/reports/apidocs/ - Push the contents into the
javadocbranch
(In case Paper didn't provide the remapping for a particular version)
mvn install:install-file -Dfile=C:/Progetti/Minecraft/Spigot/_jars/spigot/paper/paper-1.21.6.jar -DgroupId=io.papermc.paper -DartifactId=paper -Dversion=1.21.6 -Dpackaging=jar
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper</artifactId>
<version>1.21.6</version>
<scope>provided</scope>
</dependency>This happens when mappings are out of date.
To fix that delete the .paper-nms maps and run paper-nms:init for each version you got the issue.
TODO:
Find a way to fix the fact that javadocs are empty on the FastNbt-jar module and the source is empty too.