1
0

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
This commit is contained in:
madmaxoft@gmail.com
2013-06-02 21:21:32 +00:00
parent 098c237a39
commit 73f787feb3
5 changed files with 42 additions and 8 deletions

View File

@@ -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());
}
}