Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemAxe.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemHandler.h"
5 
6 
7 
8 
9 
11  public cItemHandler
12 {
14 public:
15  cItemAxeHandler(int a_ItemType)
16  : cItemHandler(a_ItemType)
17  {
18  }
19 
20 
21 
22  virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
23  {
24  switch (a_Action)
25  {
26  case dlaAttackEntity: return 2;
27  case dlaBreakBlock: return 1;
28  case dlaBreakBlockInstant: return 0;
29  }
30  UNREACHABLE("Unsupported durability loss action");
31  }
32 
33 
34 
35  virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
36  {
37  if (!IsBlockMaterialWood(a_Block) && !IsBlockMaterialPlants(a_Block) && !IsBlockMaterialVine(a_Block))
38  {
39  return super::GetBlockBreakingStrength(a_Block);
40  }
41  else
42  {
43  switch (m_ItemType)
44  {
45  case E_ITEM_WOODEN_AXE: return 2.0f;
46  case E_ITEM_STONE_AXE: return 4.0f;
47  case E_ITEM_IRON_AXE: return 6.0f;
48  case E_ITEM_GOLD_AXE: return 12.0f;
49  case E_ITEM_DIAMOND_AXE: return 8.0f;
50  }
51  }
52  ASSERT(!"Something is wrong here... Maybe they are axes out of a new material?");
53  return 1.0f;
54  }
55 
56 } ;
bool IsBlockMaterialVine(BLOCKTYPE a_BlockType)
Definition: Defines.h:659
bool IsBlockMaterialPlants(BLOCKTYPE a_BlockType)
Definition: Defines.h:624
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
Returns the strength to break a specific block.
Definition: ItemAxe.h:35
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block)
Returns the strength to break a specific block.
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
Get the durability lost which the item will get, when a specified action was performed.
Definition: ItemAxe.h:22
cItemAxeHandler(int a_ItemType)
Definition: ItemAxe.h:15
bool IsBlockMaterialWood(BLOCKTYPE a_BlockType)
Definition: Defines.h:561
#define ASSERT(x)
Definition: Globals.h:335
cItemHandler super
Definition: ItemAxe.h:13
eDurabilityLostAction
Actions that may cause durability of an item may be lost, where the magnitude of the loss depends on ...
Definition: ItemHandler.h:27
#define UNREACHABLE(x)
Use to mark code that should be impossible to reach.
Definition: Globals.h:344