// Creating a new NBTTagCompound object NBTTagCompound tag = new NBTTagCompound(); // Adding some key-value pairs tag.setString("name", "John"); tag.setInteger("age", 20); tag.setBoolean("isAdmin", false); // Retrieving values from NBTTagCompound String name = tag.getString("name"); int age = tag.getInteger("age"); boolean isAdmin = tag.getBoolean("isAdmin");
// Creating a new NBTTagCompound object NBTTagCompound tag = new NBTTagCompound(); // Adding some key-value pairs tag.setString("name", "John"); tag.setInteger("age", 20); tag.setBoolean("isAdmin", false); // Serializing the tag to a byte array byte[] bytes = tag.toByteArray(); // Deserializing the byte array to NBTTagCompound NBTTagCompound tag2 = NBTCompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); // Retrieving values from tag2 String name = tag2.getString("name"); int age = tag2.getInteger("age"); boolean isAdmin = tag2.getBoolean("isAdmin");The package library for NBTTagCompound is net.minecraft.nbt, which is part of Minecraft game's internal code.