Cuberite
A lightweight, fast and extensible game server for Minecraft
ItemShovel.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "ItemHandler.h"
5 #include "../World.h"
6 #include "../Entities/Player.h"
7 
8 
9 #include "../BlockInServerPluginInterface.h"
10 
11 
12 
13 
14 
16 {
18 public:
19  cItemShovelHandler(int a_ItemType)
20  : cItemHandler(a_ItemType)
21  {
22  }
23 
24 
25 
26  virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
27  {
28  switch (a_Action)
29  {
30  case dlaAttackEntity: return 2;
31  case dlaBreakBlock: return 1;
32  case dlaBreakBlockInstant: return 0;
33  }
34  UNREACHABLE("Unsupported durability loss action");
35  }
36 
37 
38 
39 
40 
41  virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
42  {
43  if (a_BlockType == E_BLOCK_SNOW)
44  {
45  return true;
46  }
47  return super::CanHarvestBlock(a_BlockType);
48  }
49 
50 
51 
52 
53 
54  virtual bool CanRepairWithRawMaterial(short a_ItemType) override
55  {
56  switch (m_ItemType)
57  {
58  case E_ITEM_WOODEN_SHOVEL: return (a_ItemType == E_BLOCK_PLANKS);
59  case E_ITEM_STONE_SHOVEL: return (a_ItemType == E_BLOCK_COBBLESTONE);
60  case E_ITEM_IRON_SHOVEL: return (a_ItemType == E_ITEM_IRON);
61  case E_ITEM_GOLD_SHOVEL: return (a_ItemType == E_ITEM_GOLD);
62  case E_ITEM_DIAMOND_SHOVEL: return (a_ItemType == E_ITEM_DIAMOND);
63  }
64  return false;
65  }
66 
67 
68 
69 
70 
71  virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
72  {
73  switch (a_Block)
74  {
75  case E_BLOCK_CLAY:
77  case E_BLOCK_DIRT:
78  case E_BLOCK_FARMLAND:
79  case E_BLOCK_GRASS:
80  case E_BLOCK_GRASS_PATH:
81  case E_BLOCK_GRAVEL:
82  case E_BLOCK_MYCELIUM:
83  case E_BLOCK_SAND:
84  case E_BLOCK_SNOW:
85  case E_BLOCK_SNOW_BLOCK:
86  case E_BLOCK_SOULSAND:
87  {
88  switch (m_ItemType)
89  {
90  case E_ITEM_WOODEN_SHOVEL: return 2.0f;
91  case E_ITEM_STONE_SHOVEL: return 4.0f;
92  case E_ITEM_IRON_SHOVEL: return 6.0f;
93  case E_ITEM_GOLD_SHOVEL: return 12.0f;
94  case E_ITEM_DIAMOND_SHOVEL: return 8.0f;
95  }
96  break;
97  }
98  }
99  return super::GetBlockBreakingStrength(a_Block);
100  }
101 };
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType)
Returns whether this tool / item can harvest a specific block (e.g.
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
Get the durability lost which the item will get, when a specified action was performed.
Definition: ItemShovel.h:26
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block)
Returns the strength to break a specific block.
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
Can the anvil repair this item, when a_Item is the second input?
Definition: ItemShovel.h:54
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
Returns the strength to break a specific block.
Definition: ItemShovel.h:71
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
Returns whether this tool / item can harvest a specific block (e.g.
Definition: ItemShovel.h:41
cItemShovelHandler(int a_ItemType)
Definition: ItemShovel.h:19
cItemHandler super
Definition: ItemShovel.h:17
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