From 396739cc0faf01a099acbe669c5a9def98d3aaae Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 23 Jul 2014 16:32:09 +0200 Subject: Fix item durability. Fixes #1181 --- src/Items/ItemHandler.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/Items/ItemHandler.h') diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index c7362c5f4..28b1dd13b 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -19,6 +19,13 @@ class cPlayer; class cItemHandler { public: + + enum eDurabilityLostAction + { + dlaBreakBlock, + dlaAttackEntity, + }; + cItemHandler(int a_ItemType); /** Force virtual destructor */ @@ -48,11 +55,17 @@ public: virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace); /** Called when the player destroys a block using this item. This also calls the drop function for the destroyed block */ - virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_X, int a_Y, int a_Z); + virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ); + + /** Called when a player attacks a other entity. */ + virtual void OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity); /** Called after the player has eaten this item. */ virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item); - + + /** Get the durability lost which the item will get, when a specified action was performed. */ + virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action); + /** Returns the maximum stack size for a given item */ virtual char GetMaxStackSize(void); -- cgit v1.2.3 From 4de8f5ca2926068eb855ba19c35de2a63ddebf28 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 26 Jul 2014 13:26:14 +0200 Subject: Rename function. --- src/Items/ItemHandler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items/ItemHandler.h') diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 28b1dd13b..1d5f59f3e 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -64,7 +64,7 @@ public: virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item); /** Get the durability lost which the item will get, when a specified action was performed. */ - virtual short GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action); + virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action); /** Returns the maximum stack size for a given item */ virtual char GetMaxStackSize(void); -- cgit v1.2.3