diff --git a/source/items/Item.cpp b/source/items/Item.cpp index 35a612434..47c0852e9 100644 --- a/source/items/Item.cpp +++ b/source/items/Item.cpp @@ -237,6 +237,22 @@ void cItemHandler::OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item +char cItemHandler::GetMaxStackSize(void) +{ + if (m_ItemID < 256) + { + // All blocks can stack up to 64 + return 64; + } + + // By default items don't stack: + return 1; +} + + + + + bool cItemHandler::IsTool() { return diff --git a/source/items/Item.h b/source/items/Item.h index a465ae80a..5fe260fd8 100644 --- a/source/items/Item.h +++ b/source/items/Item.h @@ -1,10 +1,19 @@ + #pragma once #include "../Defines.h" + + + + +// fwd: class cWorld; class cPlayer; + + + class cItemHandler { public: @@ -13,6 +22,9 @@ public: virtual bool OnDiggingBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir); virtual void OnBlockDestroyed(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z); virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item); + + /// Returns the maximum stack size for a given item + virtual char GetMaxStackSize(void); struct FoodInfo {