summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-06-07 22:45:00 +0200
committerarchshift <admin@archshift.com>2014-06-17 20:39:19 +0200
commit1eb04a48ee3ec4114adc4334e6fbcc7561834025 (patch)
tree6107d38a80cf4f4584f0d3edb6610f67148fa8e2 /src/Items
parentPawn.cpp: fixed effect iterator BAD_ACCESS (diff)
downloadcuberite-1eb04a48ee3ec4114adc4334e6fbcc7561834025.tar
cuberite-1eb04a48ee3ec4114adc4334e6fbcc7561834025.tar.gz
cuberite-1eb04a48ee3ec4114adc4334e6fbcc7561834025.tar.bz2
cuberite-1eb04a48ee3ec4114adc4334e6fbcc7561834025.tar.lz
cuberite-1eb04a48ee3ec4114adc4334e6fbcc7561834025.tar.xz
cuberite-1eb04a48ee3ec4114adc4334e6fbcc7561834025.tar.zst
cuberite-1eb04a48ee3ec4114adc4334e6fbcc7561834025.zip
Diffstat (limited to 'src/Items')
-rw-r--r--src/Items/ItemHandler.cpp19
-rw-r--r--src/Items/ItemHandler.h3
-rw-r--r--src/Items/ItemMilk.h26
3 files changed, 47 insertions, 1 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 67740e860..83be87b9e 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -19,6 +19,7 @@
#include "ItemCloth.h"
#include "ItemComparator.h"
#include "ItemDoor.h"
+#include "ItemMilk.h"
#include "ItemDye.h"
#include "ItemEmptyMap.h"
#include "ItemFishingRod.h"
@@ -119,6 +120,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType);
case E_BLOCK_LILY_PAD: return new cItemLilypadHandler(a_ItemType);
case E_ITEM_MAP: return new cItemMapHandler();
+ case E_ITEM_MILK: return new cItemMilkHandler();
case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType);
case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType);
case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType);
@@ -475,7 +477,6 @@ bool cItemHandler::IsFood(void)
case E_ITEM_BREAD:
case E_ITEM_RAW_PORKCHOP:
case E_ITEM_COOKED_PORKCHOP:
- case E_ITEM_MILK:
case E_ITEM_RAW_FISH:
case E_ITEM_COOKED_FISH:
case E_ITEM_COOKIE:
@@ -501,6 +502,22 @@ bool cItemHandler::IsFood(void)
+bool cItemHandler::IsDrinkable(void)
+{
+ switch (m_ItemType)
+ {
+ case E_ITEM_MILK:
+ {
+ return true;
+ }
+ } // switch (m_ItemType)
+ return false;
+}
+
+
+
+
+
bool cItemHandler::IsPlaceable(void)
{
// We can place any block that has a corresponding E_BLOCK_TYPE:
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index e13198cd7..3a25a3f9d 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -82,6 +82,9 @@ public:
/** Indicates if this item is food */
virtual bool IsFood(void);
+ /** Indicates if this item is drinkable */
+ virtual bool IsDrinkable(void);
+
/** Blocks simply get placed */
virtual bool IsPlaceable(void);
diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h
new file mode 100644
index 000000000..8569c8cbe
--- /dev/null
+++ b/src/Items/ItemMilk.h
@@ -0,0 +1,26 @@
+
+#pragma once
+
+class cItemMilkHandler:
+ public cItemHandler
+{
+ typedef cItemHandler super;
+public:
+ cItemMilkHandler():
+ super(E_ITEM_MILK)
+ {
+ }
+
+ virtual bool IsDrinkable(void) override
+ {
+ return true;
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ a_Player->ClearEntityEffects();
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ a_Player->GetInventory().AddItem(E_ITEM_BUCKET);
+ return true;
+ }
+};