1
0
cuberite-2a/src/Items/ItemShovel.h

105 lines
1.9 KiB
C
Raw Normal View History

#pragma once
#include "ItemHandler.h"
#include "../World.h"
#include "../Entities/Player.h"
2017-08-06 15:57:44 -04:00
2014-02-02 09:49:37 -05:00
#include "../BlockInServerPluginInterface.h"
2020-04-13 12:38:06 -04:00
class cItemShovelHandler:
public cItemHandler
{
2020-04-13 12:38:06 -04:00
using Super = cItemHandler;
public:
2020-04-13 12:38:06 -04:00
cItemShovelHandler(int a_ItemType):
Super(a_ItemType)
{
}
virtual short GetDurabilityLossByAction(eDurabilityLostAction a_Action) override
{
switch (a_Action)
{
case dlaAttackEntity: return 2;
case dlaBreakBlock: return 1;
case dlaBreakBlockInstant: return 0;
}
UNREACHABLE("Unsupported durability loss action");
}
2016-02-05 16:45:45 -05:00
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
{
if (a_BlockType == E_BLOCK_SNOW)
{
return true;
}
2020-04-13 12:38:06 -04:00
return Super::CanHarvestBlock(a_BlockType);
}
2014-04-30 18:47:57 -04:00
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
2014-04-30 18:47:57 -04:00
{
switch (m_ItemType)
{
case E_ITEM_WOODEN_SHOVEL: return (a_ItemType == E_BLOCK_PLANKS);
case E_ITEM_STONE_SHOVEL: return (a_ItemType == E_BLOCK_COBBLESTONE);
case E_ITEM_IRON_SHOVEL: return (a_ItemType == E_ITEM_IRON);
case E_ITEM_GOLD_SHOVEL: return (a_ItemType == E_ITEM_GOLD);
case E_ITEM_DIAMOND_SHOVEL: return (a_ItemType == E_ITEM_DIAMOND);
2014-04-30 18:47:57 -04:00
}
return false;
}
2016-11-13 10:21:30 -05:00
virtual float GetBlockBreakingStrength(BLOCKTYPE a_Block) override
{
switch (a_Block)
{
case E_BLOCK_CLAY:
2017-06-30 04:46:58 -04:00
case E_BLOCK_CONCRETE_POWDER:
case E_BLOCK_DIRT:
case E_BLOCK_FARMLAND:
case E_BLOCK_GRASS:
2017-02-14 05:13:55 -05:00
case E_BLOCK_GRASS_PATH:
case E_BLOCK_GRAVEL:
case E_BLOCK_MYCELIUM:
case E_BLOCK_SAND:
case E_BLOCK_SNOW:
case E_BLOCK_SNOW_BLOCK:
case E_BLOCK_SOULSAND:
{
switch (m_ItemType)
{
case E_ITEM_WOODEN_SHOVEL: return 2.0f;
case E_ITEM_STONE_SHOVEL: return 4.0f;
case E_ITEM_IRON_SHOVEL: return 6.0f;
case E_ITEM_GOLD_SHOVEL: return 12.0f;
case E_ITEM_DIAMOND_SHOVEL: return 8.0f;
}
break;
}
}
2020-04-13 12:38:06 -04:00
return Super::GetBlockBreakingStrength(a_Block);
}
2014-02-02 09:49:37 -05:00
};