How would I go about adding lore to an ItemStack?
Here is my current code:
CompoundNBT nbt = item.getTag();
CompoundNBT display;
ListNBT lore;
if (nbt.get("display") != null) {
display = (CompoundNBT) nbt.get("display");
if (display.get("Lore") != null) {
lore = (ListNBT) display.get("Lore");
} else {
lore = new ListNBT();
}
} else {
lore = new ListNBT();
display = new CompoundNBT();
}
CompoundNBT tagRawJson = new CompoundNBT();
tagRawJson.putString("tag", "{'text': '[tag]', 'italic': false, 'color': 'white'}".replace("[tag]", tag));
lore.add(tagRawJson.get("tag"));
display.put("Lore", lore);
nbt.put("display", display);
item.setTag(nbt);
I would like to add the contents of the String variable named tag to the lore.