Explanation
Rtag is made of multiple classes that work together to handle NBT.
Structureβ
Tag Objectsβ
Rtag contains multiple utility classes to handle NBT objects maintaining a cross-version compatibility, including the conversion of respective object to Java and vice versa.
For more information about tag objects:
ποΈ Tag Objects
Information about Rtag handling NBT
Tag Mirrorβ
It's the superclass of Rtag to convert any object (String, Integer, List, Map) into NBT and vice versa in a simple way using TagObject classes.
// Create mirror
RtagMirror mirror = new RtagMirror();
// Use public instance
RtagMirror mirror = RtagMirror.INSTANCE;
// Create object
String myObject = "Hello";
// Convert to NBT
Object nbtTag = mirror.newTag(myObject);
// Copy NBT
Object nbtTagCopy = mirror.copy(nbtTag);
// Get the java value from NBT object
String sameObject = (String) mirror.getTagValue(nbtTag);
Main Rtag instanceβ
It's the Rtag itself, with this instance you can edit any NBTTagCompound
and NBTTagList
in a simple way, you can add and remove objects using a tree-like path format.
Including compatibility with custom objects by registering an object (de)serializer.
// Create Rtag
Rtag rtag = new Rtag();
// Use public instance
Rtag rtag = Rtag.INSTANCE;
// NBTTagCompound object
Object compound = ...;
String str = "My String";
// Set into "my -> saved -> object" path
rtag.set(compound, str, "my", "saved", "object");
// Get from "my <- save <- object"
String sameStr = rtag.get(compound, "my", "saved", "object");
// Remove from path
rtag.remove(compound, "my", "saved", "object");
For more information about custom objects:
ποΈ Custom Objects
How to save and get custom objects in Rtag
Minecraft Objectsβ
Various types of utility classes to interact hover CraftBukkit objects and Minecraft objects using reflected methods.
ποΈ Minecraft Objects
Information about minecraft objects in Rtag
Mojang Codecsβ
To implement data old data conversion, Mojang create DataFixerUpper library as a flexible way to decode and encode data.
ποΈ Mojang Codecs
Information about codecs usage and serialization
Data Componentsβ
Since MC 1.20.5 item format has changed and Mojang introduces data components to handle vanilla tags in a optimized way.
ποΈ Data Component
Information about data component object usage