summaryrefslogtreecommitdiffstats
path: root/src/Item.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-04-03 08:57:01 +0200
committerGitHub <noreply@github.com>2020-04-03 08:57:01 +0200
commit01b8ed5295875262a91b60af878bf2a18c1b7aae (patch)
tree52171974791a7529a3a69f9fe20d906158765954 /src/Item.cpp
parentUpdate Core (diff)
downloadcuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar
cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.gz
cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.bz2
cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.lz
cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.xz
cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.tar.zst
cuberite-01b8ed5295875262a91b60af878bf2a18c1b7aae.zip
Diffstat (limited to '')
-rw-r--r--src/Item.cpp80
1 files changed, 79 insertions, 1 deletions
diff --git a/src/Item.cpp b/src/Item.cpp
index 16aa22b50..dd8f08f02 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Item.h"
+#include "BlockType.h"
#include "ItemGrid.h"
#include "json/json.h"
#include "Items/ItemHandler.h"
@@ -12,6 +13,83 @@
+cItem::cItem():
+ m_ItemType(E_ITEM_EMPTY),
+ m_ItemCount(0),
+ m_ItemDamage(0),
+ m_CustomName(""),
+ m_RepairCost(0),
+ m_FireworkItem(),
+ m_ItemColor()
+{
+}
+
+
+
+
+
+cItem::cItem(
+ short a_ItemType,
+ char a_ItemCount,
+ short a_ItemDamage,
+ const AString & a_Enchantments,
+ const AString & a_CustomName,
+ const AStringVector & a_LoreTable
+):
+ m_ItemType (a_ItemType),
+ m_ItemCount (a_ItemCount),
+ m_ItemDamage (a_ItemDamage),
+ m_Enchantments(a_Enchantments),
+ m_CustomName (a_CustomName),
+ m_LoreTable (a_LoreTable),
+ m_RepairCost (0),
+ m_FireworkItem(),
+ m_ItemColor()
+{
+ if (!IsValidItem(m_ItemType))
+ {
+ if ((m_ItemType != E_BLOCK_AIR) && (m_ItemType != E_ITEM_EMPTY))
+ {
+ LOGWARNING("%s: creating an invalid item type (%d), resetting to empty.", __FUNCTION__, a_ItemType);
+ }
+ Empty();
+ }
+}
+
+
+
+
+
+void cItem::Empty()
+{
+ m_ItemType = E_ITEM_EMPTY;
+ m_ItemCount = 0;
+ m_ItemDamage = 0;
+ m_Enchantments.Clear();
+ m_CustomName = "";
+ m_LoreTable.clear();
+ m_RepairCost = 0;
+ m_FireworkItem.EmptyData();
+ m_ItemColor.Clear();
+}
+
+
+
+
+
+void cItem::Clear()
+{
+ m_ItemType = E_ITEM_EMPTY;
+ m_ItemCount = 0;
+ m_ItemDamage = 0;
+ m_RepairCost = 0;
+ m_ItemColor.Clear();
+}
+
+
+
+
+
cItem cItem::CopyOne(void) const
{
cItem res(*this);
@@ -196,7 +274,7 @@ void cItem::GetJson(Json::Value & a_OutValue) const
void cItem::FromJson(const Json::Value & a_Value)
{
- m_ItemType = static_cast<ENUM_ITEM_ID>(a_Value.get("ID", -1).asInt());
+ m_ItemType = static_cast<ENUM_ITEM_TYPE>(a_Value.get("ID", -1).asInt());
if (m_ItemType > 0)
{
m_ItemCount = static_cast<char>(a_Value.get("Count", -1).asInt());