summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp15
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp12
2 files changed, 22 insertions, 5 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index d474f59e1..480558fa3 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -107,7 +107,7 @@ void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AStrin
((a_Item.m_ItemType == E_ITEM_FIREWORK_ROCKET) || (a_Item.m_ItemType == E_ITEM_FIREWORK_STAR)) ||
(a_Item.m_RepairCost > 0) ||
(a_Item.m_CustomName != "") ||
- (a_Item.m_Lore != "")
+ (!a_Item.m_LoreTable.empty())
)
{
m_Writer.BeginCompound("tag");
@@ -116,16 +116,23 @@ void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AStrin
m_Writer.AddInt("RepairCost", a_Item.m_RepairCost);
}
- if ((a_Item.m_CustomName != "") || (a_Item.m_Lore != ""))
+ if ((a_Item.m_CustomName != "") || (!a_Item.m_LoreTable.empty()))
{
m_Writer.BeginCompound("display");
if (a_Item.m_CustomName != "")
{
m_Writer.AddString("Name", a_Item.m_CustomName);
}
- if (a_Item.m_Lore != "")
+ if (!a_Item.m_LoreTable.empty())
{
- m_Writer.AddString("Lore", a_Item.m_Lore);
+ m_Writer.BeginList("Lore", TAG_String);
+
+ for (const auto & Line : a_Item.m_LoreTable)
+ {
+ m_Writer.AddString("", Line);
+ }
+
+ m_Writer.EndList();
}
m_Writer.EndCompound();
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 14d5738c2..77d1e46b8 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -804,7 +804,17 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_
int Lore = a_NBT.FindChildByName(DisplayTag, "Lore");
if ((Lore > 0) && (a_NBT.GetType(Lore) == TAG_String))
{
- a_Item.m_Lore = a_NBT.GetString(Lore);
+ // Legacy string lore
+ a_Item.m_LoreTable = StringSplit(a_NBT.GetString(Lore), "`");
+ }
+ else if ((Lore > 0) && (a_NBT.GetType(Lore) == TAG_List))
+ {
+ // Lore table
+ a_Item.m_LoreTable.clear();
+ for (int loretag = a_NBT.GetFirstChild(Lore); loretag >= 0; loretag = a_NBT.GetNextSibling(loretag)) // Loop through array of strings
+ {
+ a_Item.m_LoreTable.push_back(a_NBT.GetString(loretag));
+ }
}
}