summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemHandler.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-07-27 21:39:39 +0200
committerMattes D <github@xoft.cz>2014-07-27 21:39:39 +0200
commit0814a977f8a99fb776a73b44bff14b2a6fb11059 (patch)
treeedd7271430e1c0204808b3c12b7735959677b733 /src/Items/ItemHandler.cpp
parentNetherClumpGenerator: Fixed generating stuff on halfslabs and fences (diff)
parentDerp. (diff)
downloadcuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.gz
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.bz2
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.lz
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.xz
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.zst
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemHandler.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 23dbb4348..ec86648b3 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -332,8 +332,21 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const
cBlockInServerPluginInterface PluginInterface(*a_World);
Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block), a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) > 0);
}
-
- a_Player->UseEquippedItem();
+
+ if (!cBlockInfo::IsOneHitDig(Block))
+ {
+ a_Player->UseEquippedItem(GetDurabilityLossByAction(dlaBreakBlock));
+ }
+}
+
+
+
+
+
+void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity)
+{
+ UNUSED(a_AttackedEntity);
+ a_Attacker->UseEquippedItem(GetDurabilityLossByAction(dlaAttackEntity));
}
@@ -351,6 +364,20 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I
+short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action)
+{
+ switch (a_Action)
+ {
+ case dlaAttackEntity: return 2;
+ case dlaBreakBlock: return 1;
+ }
+ return 0;
+}
+
+
+
+
+
char cItemHandler::GetMaxStackSize(void)
{
if (m_ItemType < 256)
@@ -502,6 +529,7 @@ bool cItemHandler::IsPlaceable(void)
bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
{
+ UNUSED(a_ItemType);
return false;
}
@@ -548,6 +576,8 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
case E_BLOCK_IRON_ORE:
case E_BLOCK_LAPIS_ORE:
case E_BLOCK_LAPIS_BLOCK:
+ case E_BLOCK_SNOW:
+ case E_BLOCK_VINES:
{
return false;
}