diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-02 23:21:32 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-02 23:21:32 +0200 |
commit | 73f787feb328ffe349d803ca01363ba57178760b (patch) | |
tree | f3be3b285756e5d56aa602924dd4eee0db14735d /source/Item.cpp | |
parent | Shift + click doesn't "destroy" item enchantment (diff) | |
download | cuberite-73f787feb328ffe349d803ca01363ba57178760b.tar cuberite-73f787feb328ffe349d803ca01363ba57178760b.tar.gz cuberite-73f787feb328ffe349d803ca01363ba57178760b.tar.bz2 cuberite-73f787feb328ffe349d803ca01363ba57178760b.tar.lz cuberite-73f787feb328ffe349d803ca01363ba57178760b.tar.xz cuberite-73f787feb328ffe349d803ca01363ba57178760b.tar.zst cuberite-73f787feb328ffe349d803ca01363ba57178760b.zip |
Diffstat (limited to 'source/Item.cpp')
-rw-r--r-- | source/Item.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/source/Item.cpp b/source/Item.cpp index e2cacdac1..569d04980 100644 --- a/source/Item.cpp +++ b/source/Item.cpp @@ -90,23 +90,34 @@ bool cItem::IsStackableWith(const cItem & a_OtherStack) const -void cItem::GetJson( Json::Value & a_OutValue ) const +void cItem::GetJson(Json::Value & a_OutValue) const { a_OutValue["ID"] = m_ItemType; - if( m_ItemType > 0 ) + if (m_ItemType > 0) { a_OutValue["Count"] = m_ItemCount; a_OutValue["Health"] = m_ItemDamage; + AString Enchantments(m_Enchantments.ToString()); + if (!Enchantments.empty()) + { + a_OutValue["ench"] = Enchantments; + } } } -void cItem::FromJson( const Json::Value & a_Value ) + + + + +void cItem::FromJson(const Json::Value & a_Value) { m_ItemType = (ENUM_ITEM_ID)a_Value.get("ID", -1 ).asInt(); - if( m_ItemType > 0 ) + if (m_ItemType > 0) { m_ItemCount = (char)a_Value.get("Count", -1 ).asInt(); m_ItemDamage = (short)a_Value.get("Health", -1 ).asInt(); + m_Enchantments.Clear(); + m_Enchantments.AddFromString(a_Value.get("ench", "").asString()); } } |