summaryrefslogtreecommitdiffstats
path: root/src/Item.cpp
diff options
context:
space:
mode:
authorLukas Pioch <lukas@zgow.de>2017-07-28 12:11:07 +0200
committerLukas Pioch <lukas@zgow.de>2017-08-27 14:54:40 +0200
commitc171b272d96453f1a9d13d4623ac4bd3aa7d19e8 (patch)
tree32828d71b3de14de7489b080f07066dcf49e913e /src/Item.cpp
parentImplement anvil chunk sparsing (diff)
downloadcuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.gz
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.bz2
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.lz
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.xz
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.zst
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.zip
Diffstat (limited to 'src/Item.cpp')
-rw-r--r--src/Item.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/Item.cpp b/src/Item.cpp
index 9b17f1c37..412c66ec3 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -183,6 +183,31 @@ void cItem::GetJson(Json::Value & a_OutValue) const
a_OutValue["FadeColours"] = m_FireworkItem.FadeColoursToString(m_FireworkItem);
}
+ if (
+ !m_BookContent.IsEmpty() &&
+ (
+ (m_ItemType == E_ITEM_WRITTEN_BOOK) || (m_ItemType == E_ITEM_BOOK_AND_QUILL)
+ )
+ )
+ {
+ if (!m_BookContent.GetAuthor().empty())
+ {
+ a_OutValue["author"] = m_BookContent.GetAuthor();
+ }
+ if (!m_BookContent.GetTitle().empty())
+ {
+ a_OutValue["title"] = m_BookContent.GetTitle();
+ }
+ if (!m_BookContent.GetPages().empty())
+ {
+ a_OutValue["pages"] = Json::Value(Json::arrayValue);
+ for (const auto & Page : m_BookContent.GetPages())
+ {
+ a_OutValue["pages"].append(Page);
+ }
+ }
+ }
+
a_OutValue["RepairCost"] = m_RepairCost;
}
}
@@ -229,6 +254,19 @@ void cItem::FromJson(const Json::Value & a_Value)
m_FireworkItem.FadeColoursFromString(a_Value.get("FadeColours", "").asString(), m_FireworkItem);
}
+ if ((m_ItemType == E_ITEM_WRITTEN_BOOK) || (m_ItemType == E_ITEM_BOOK_AND_QUILL))
+ {
+ m_BookContent.SetAuthor(a_Value.get("author", "").asString());
+ m_BookContent.SetTitle(a_Value.get("title", "").asString());
+ if (a_Value.isMember("pages"))
+ {
+ for (Json::Value::ArrayIndex i = 0; i != a_Value["pages"].size(); i++)
+ {
+ m_BookContent.AddPage(a_Value["pages"][i].asString());
+ }
+ }
+ }
+
m_RepairCost = a_Value.get("RepairCost", 0).asInt();
}
}