summaryrefslogtreecommitdiffstats
path: root/src/Item.cpp
diff options
context:
space:
mode:
authorJulian Laubstein <julianlaubstein@yahoo.de>2015-07-15 22:31:48 +0200
committerJulian Laubstein <julianlaubstein@yahoo.de>2015-07-15 22:31:48 +0200
commit8b74adcfab2a39b8d663f9ebc21cc4cde42761ef (patch)
treebbb45c47667db874f73f57fd8fa55bac4f5f72c4 /src/Item.cpp
parentMerge pull request #2350 from SamJBarney/PeonySnowFix (diff)
parentLeather Armor can now be dyed. (diff)
downloadcuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.gz
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.bz2
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.lz
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.xz
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.tar.zst
cuberite-8b74adcfab2a39b8d663f9ebc21cc4cde42761ef.zip
Diffstat (limited to 'src/Item.cpp')
-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();