From 3c102870f600178b7cabf6714f83e06fc05b42fd Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 1 May 2014 00:47:57 +0200 Subject: Add anvil window and slot area. --- src/Items/ItemHandler.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Items/ItemHandler.h') diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index 4993eac85..420eefcf1 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -85,6 +85,12 @@ public: /** Blocks simply get placed */ virtual bool IsPlaceable(void); + /** Can the anvil repair this item, when a_Item is the second input? */ + virtual bool CanRepairWithItem(const cItem & a_Item); + + /** Get the repair cost from the item, or 0 if the item hasn't repair cost. */ + virtual int GetRepairCost(void); + /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. -- cgit v1.2.3 From 954b59d6f460106e93efab39c8666d4692db25b6 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 6 May 2014 19:38:09 +0200 Subject: Rename CanRepairWithItem to CanRepairWithRawMaterial and rename Size() to Count() --- 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 420eefcf1..ca090eb29 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -86,7 +86,7 @@ public: virtual bool IsPlaceable(void); /** Can the anvil repair this item, when a_Item is the second input? */ - virtual bool CanRepairWithItem(const cItem & a_Item); + virtual bool CanRepairWithRawMaterial(short a_ItemType); /** Get the repair cost from the item, or 0 if the item hasn't repair cost. */ virtual int GetRepairCost(void); -- cgit v1.2.3 From d6cb6e0423fe38478c69f5d249882a01d727f0ed Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 7 May 2014 12:30:30 +0200 Subject: Add repair cost to cItem, add custom name to NBTChunkSerializer and fix anvil bugs. --- src/Items/ItemHandler.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/Items/ItemHandler.h') diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index ca090eb29..e13198cd7 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -88,9 +88,6 @@ public: /** Can the anvil repair this item, when a_Item is the second input? */ virtual bool CanRepairWithRawMaterial(short a_ItemType); - /** Get the repair cost from the item, or 0 if the item hasn't repair cost. */ - virtual int GetRepairCost(void); - /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. -- cgit v1.2.3 From 1eb04a48ee3ec4114adc4334e6fbcc7561834025 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 13:45:00 -0700 Subject: Implemented milk, added documentation to Pawn.h --- src/Items/ItemHandler.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Items/ItemHandler.h') 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); -- cgit v1.2.3 From 2185c72c2ca2d66b238d7d3234c173bd820d32ac Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 16:32:37 -0700 Subject: Implemented drinkable potions, noeffect entity effect, Clears entity effects on death --- 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 3a25a3f9d..ead2c9769 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -83,7 +83,7 @@ public: virtual bool IsFood(void); /** Indicates if this item is drinkable */ - virtual bool IsDrinkable(void); + virtual bool IsDrinkable(const cItem * a_Item); /** Blocks simply get placed */ virtual bool IsPlaceable(void); -- cgit v1.2.3 From 3766ac96d77329c679d01d1ab1a846384acab42f Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 17:06:15 -0700 Subject: ItemHandler: changed IsDrinkable() to take a short argument --- src/Items/ItemHandler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Items/ItemHandler.h') diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index ead2c9769..cffca11ab 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -83,7 +83,7 @@ public: virtual bool IsFood(void); /** Indicates if this item is drinkable */ - virtual bool IsDrinkable(const cItem * a_Item); + virtual bool IsDrinkable(short a_ItemDamage); /** Blocks simply get placed */ virtual bool IsPlaceable(void); @@ -102,7 +102,7 @@ public: BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ); - /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can�t) DEFAULT: False */ + /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can't) DEFAULT: False */ virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType); static cItemHandler * GetItemHandler(int a_ItemType); -- cgit v1.2.3 From 2423fbf2efa39e28cc348acc11b9269e573dcdef Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:15:34 +0200 Subject: Normalized comments. This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign. --- src/Items/ItemHandler.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Items/ItemHandler.h') diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index cffca11ab..b33671c2d 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -60,7 +60,7 @@ public: { double Saturation; int FoodLevel; - int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning + int PoisonChance; // 0 - 100, in percent. 0 = no chance of poisoning, 100 = sure poisoning FoodInfo(int a_FoodLevel, double a_Saturation, int a_PoisonChance = 0) : Saturation(a_Saturation), @@ -112,11 +112,11 @@ public: protected: int m_ItemType; - static cItemHandler *CreateItemHandler(int m_ItemType); + static cItemHandler * CreateItemHandler(int m_ItemType); static cItemHandler * m_ItemHandler[E_ITEM_LAST + 1]; - static bool m_HandlerInitialized; //used to detect if the itemhandlers are initialized + static bool m_HandlerInitialized; // used to detect if the itemhandlers are initialized }; -//Short function +// Short function inline cItemHandler *ItemHandler(int a_ItemType) { return cItemHandler::GetItemHandler(a_ItemType); } -- cgit v1.2.3 From 5e198c673009cf8ca9d92cf59848999bc96bbc37 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:50:58 +0200 Subject: Basic style fixes. --- src/Items/ItemHandler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Items/ItemHandler.h') diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index b33671c2d..3ea04d1cb 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -28,7 +28,7 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir); /** Called when the client sends the SHOOT status in the lclk packet */ - virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) + virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) { UNUSED(a_BlockX); UNUSED(a_BlockY); @@ -97,7 +97,7 @@ public: */ virtual bool GetPlacementBlockTypeMeta( cWorld * a_World, cPlayer * a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ); -- cgit v1.2.3 From d0cc9aedb3e63d39324c52b6385406f362ab41b7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:59:02 +0200 Subject: More trailing whitespace fixes. --- 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 3ea04d1cb..c7362c5f4 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -91,7 +91,7 @@ public: /** Can the anvil repair this item, when a_Item is the second input? */ virtual bool CanRepairWithRawMaterial(short a_ItemType); - /** Called before a block is placed into a world. + /** Called before a block is placed into a world. The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. */ -- cgit v1.2.3 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