From 73f787feb328ffe349d803ca01363ba57178760b Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 2 Jun 2013 21:21:32 +0000 Subject: Enchantments are now stored in Anvil world and in player inventory git-svn-id: http://mc-server.googlecode.com/svn/trunk@1541 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Item.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source/Item.cpp') 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()); } } -- cgit v1.2.3