summaryrefslogtreecommitdiffstats
path: root/src/Item.cpp
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2015-07-14 02:15:37 +0200
committerSamuel Barney <samjbarney@gmail.com>2015-07-15 22:05:36 +0200
commit561296f2699bcfff93d22b8a67182308998cfb31 (patch)
tree7e0c13beb4b3933923d57c5755b82c76da1a9db9 /src/Item.cpp
parentMerge pull request #2347 from SamJBarney/ClampFix (diff)
downloadcuberite-561296f2699bcfff93d22b8a67182308998cfb31.tar
cuberite-561296f2699bcfff93d22b8a67182308998cfb31.tar.gz
cuberite-561296f2699bcfff93d22b8a67182308998cfb31.tar.bz2
cuberite-561296f2699bcfff93d22b8a67182308998cfb31.tar.lz
cuberite-561296f2699bcfff93d22b8a67182308998cfb31.tar.xz
cuberite-561296f2699bcfff93d22b8a67182308998cfb31.tar.zst
cuberite-561296f2699bcfff93d22b8a67182308998cfb31.zip
Diffstat (limited to '')
-rw-r--r--src/Item.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Item.cpp b/src/Item.cpp
index 36c444328..7bd344ae8 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -142,6 +142,13 @@ void cItem::GetJson(Json::Value & a_OutValue) const
a_OutValue["Lore"] = m_Lore;
}
+ if (m_ItemColor.IsValid())
+ {
+ a_OutValue["Color_Red"] = m_ItemColor.GetRed();
+ a_OutValue["Color_Green"] = m_ItemColor.GetGreen();
+ a_OutValue["Color_Blue"] = m_ItemColor.GetBlue();
+ }
+
if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
{
a_OutValue["Flicker"] = m_FireworkItem.m_HasFlicker;
@@ -172,6 +179,18 @@ void cItem::FromJson(const Json::Value & a_Value)
m_CustomName = a_Value.get("Name", "").asString();
m_Lore = a_Value.get("Lore", "").asString();
+ int red = a_Value.get("Color_Red", -1).asInt();
+ int green = a_Value.get("Color_Green", -1).asInt();
+ int blue = a_Value.get("Color_Blue", -1).asInt();
+ if ((red > -1) && (red < static_cast<int>(cColor::COLOR_LIMIT)) && (green > -1) && (green < static_cast<int>(cColor::COLOR_LIMIT)) && (blue > -1) && (blue < static_cast<int>(cColor::COLOR_LIMIT)))
+ {
+ m_ItemColor.SetColor(static_cast<unsigned char>(red), static_cast<unsigned char>(green), static_cast<unsigned char>(blue));
+ }
+ else if ((red != -1) || (blue != -1) || (green != -1))
+ {
+ LOGWARNING("Item with invalid red, green, and blue values read in from json file.");
+ }
+
if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
{
m_FireworkItem.m_HasFlicker = a_Value.get("Flicker", false).asBool();