summaryrefslogtreecommitdiffstats
path: root/src/Item.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-04-03 22:03:18 +0200
committerHowaner <franzi.moos@googlemail.com>2014-04-03 22:03:18 +0200
commit32d054e8fdad1d486fd4edbb542daa3262220e5f (patch)
tree1094c471768b71e8cac1277c2fbea5a5d9f2caf9 /src/Item.cpp
parentRemove old function (diff)
parentAPIDump: Added angular specifics. (diff)
downloadcuberite-32d054e8fdad1d486fd4edbb542daa3262220e5f.tar
cuberite-32d054e8fdad1d486fd4edbb542daa3262220e5f.tar.gz
cuberite-32d054e8fdad1d486fd4edbb542daa3262220e5f.tar.bz2
cuberite-32d054e8fdad1d486fd4edbb542daa3262220e5f.tar.lz
cuberite-32d054e8fdad1d486fd4edbb542daa3262220e5f.tar.xz
cuberite-32d054e8fdad1d486fd4edbb542daa3262220e5f.tar.zst
cuberite-32d054e8fdad1d486fd4edbb542daa3262220e5f.zip
Diffstat (limited to 'src/Item.cpp')
-rw-r--r--src/Item.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/Item.cpp b/src/Item.cpp
index 9170006b6..856b68be6 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -1,4 +1,4 @@
-
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Item.h"
@@ -139,6 +139,16 @@ void cItem::GetJson(Json::Value & a_OutValue) const
{
a_OutValue["Lore"] = m_Lore;
}
+
+ if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
+ {
+ a_OutValue["Flicker"] = m_FireworkItem.m_HasFlicker;
+ a_OutValue["Trail"] = m_FireworkItem.m_HasTrail;
+ a_OutValue["Type"] = m_FireworkItem.m_Type;
+ a_OutValue["FlightTimeInTicks"] = m_FireworkItem.m_FlightTimeInTicks;
+ a_OutValue["Colours"] = m_FireworkItem.ColoursToString(m_FireworkItem);
+ a_OutValue["FadeColours"] = m_FireworkItem.FadeColoursToString(m_FireworkItem);
+ }
}
}
@@ -157,6 +167,16 @@ void cItem::FromJson(const Json::Value & a_Value)
m_Enchantments.AddFromString(a_Value.get("ench", "").asString());
m_CustomName = a_Value.get("Name", "").asString();
m_Lore = a_Value.get("Lore", "").asString();
+
+ if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
+ {
+ m_FireworkItem.m_HasFlicker = a_Value.get("Flicker", false).asBool();
+ m_FireworkItem.m_HasTrail = a_Value.get("Trail", false).asBool();
+ m_FireworkItem.m_Type = (NIBBLETYPE)a_Value.get("Type", 0).asInt();
+ m_FireworkItem.m_FlightTimeInTicks = (short)a_Value.get("FlightTimeInTicks", 0).asInt();
+ m_FireworkItem.ColoursFromString(a_Value.get("Colours", "").asString(), m_FireworkItem);
+ m_FireworkItem.FadeColoursFromString(a_Value.get("FadeColours", "").asString(), m_FireworkItem);
+ }
}
}
@@ -196,7 +216,7 @@ cItem * cItems::Get(int a_Idx)
{
if ((a_Idx < 0) || (a_Idx >= (int)size()))
{
- LOGWARNING("cItems: Attempt to get an out-of-bounds item at index %d; there are currently %d items. Returning a nil.", a_Idx, size());
+ LOGWARNING("cItems: Attempt to get an out-of-bounds item at index %d; there are currently " SIZE_T_FMT " items. Returning a nil.", a_Idx, size());
return NULL;
}
return &at(a_Idx);
@@ -210,7 +230,7 @@ void cItems::Set(int a_Idx, const cItem & a_Item)
{
if ((a_Idx < 0) || (a_Idx >= (int)size()))
{
- LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently %d items. Not setting.", a_Idx, size());
+ LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently " SIZE_T_FMT " items. Not setting.", a_Idx, size());
return;
}
at(a_Idx) = a_Item;
@@ -224,7 +244,7 @@ void cItems::Delete(int a_Idx)
{
if ((a_Idx < 0) || (a_Idx >= (int)size()))
{
- LOGWARNING("cItems: Attempt to delete an item at an out-of-bounds index %d; there are currently %d items. Ignoring.", a_Idx, size());
+ LOGWARNING("cItems: Attempt to delete an item at an out-of-bounds index %d; there are currently " SIZE_T_FMT " items. Ignoring.", a_Idx, size());
return;
}
erase(begin() + a_Idx);
@@ -238,7 +258,7 @@ void cItems::Set(int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDama
{
if ((a_Idx < 0) || (a_Idx >= (int)size()))
{
- LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently %d items. Not setting.", a_Idx, size());
+ LOGWARNING("cItems: Attempt to set an item at an out-of-bounds index %d; there are currently " SIZE_T_FMT " items. Not setting.", a_Idx, size());
return;
}
at(a_Idx) = cItem(a_ItemType, a_ItemCount, a_ItemDamage);