From 0f8c24e04d60aa1642a5fe7346941ccd7697977e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 17 Jul 2014 22:26:53 +0100 Subject: Fixed issues relating to saplings and leaves - Removed cBlockInfo::RequiresSpecialTool * Fixes #1195 * Fixes #1201 --- src/Items/ItemHandler.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/Items/ItemHandler.cpp') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 85406c826..604cce729 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -328,12 +328,9 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const if (a_Player->IsGameModeSurvival()) { - if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block)) - { - cChunkInterface ChunkInterface(a_World->GetChunkMap()); - cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); - } + cChunkInterface ChunkInterface(a_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*a_World); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); } a_Player->UseEquippedItem(); -- 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.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/Items/ItemHandler.cpp') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index bf1d4e4cb..f0a91214d 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -335,8 +335,21 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ); } } - - a_Player->UseEquippedItem(); + + if (!cBlockInfo::IsOneHitDig(Block)) + { + a_Player->UseEquippedItem(GetDurabilityLostWithThatAction(dlaBreakBlock)); + } +} + + + + + +void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity) +{ + UNUSED(a_AttackedEntity); + a_Attacker->UseEquippedItem(GetDurabilityLostWithThatAction(dlaAttackEntity)); } @@ -354,6 +367,20 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I +short cItemHandler::GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) +{ + switch (a_Action) + { + case dlaAttackEntity: return 2; + case dlaBreakBlock: return 1; + } + return 0; +} + + + + + char cItemHandler::GetMaxStackSize(void) { if (m_ItemType < 256) @@ -505,6 +532,7 @@ bool cItemHandler::IsPlaceable(void) bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) { + UNUSED(a_ItemType); return false; } -- cgit v1.2.3 From 3a6002de5b13c1cd56d904892e5af6123978225d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 24 Jul 2014 21:38:25 +0100 Subject: Fixed block drops * Fixes #1242 (the issue addressed within) --- src/Items/ItemHandler.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'src/Items/ItemHandler.cpp') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 1671a8145..23dbb4348 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -330,7 +330,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const { cChunkInterface ChunkInterface(a_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*a_World); - Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, CanHarvestBlock(Block)); + 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(); @@ -511,9 +511,48 @@ bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType) bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) { - UNUSED(a_BlockType); - - return false; + switch (a_BlockType) + { + case E_BLOCK_ANVIL: + case E_BLOCK_ENCHANTMENT_TABLE: + case E_BLOCK_FURNACE: + case E_BLOCK_LIT_FURNACE: + case E_BLOCK_COAL_ORE: + case E_BLOCK_STONE: + case E_BLOCK_COBBLESTONE: + case E_BLOCK_END_STONE: + case E_BLOCK_MOSSY_COBBLESTONE: + case E_BLOCK_SANDSTONE_STAIRS: + case E_BLOCK_SANDSTONE: + case E_BLOCK_STONE_BRICKS: + case E_BLOCK_NETHER_BRICK: + case E_BLOCK_NETHERRACK: + case E_BLOCK_STONE_SLAB: + case E_BLOCK_DOUBLE_STONE_SLAB: + case E_BLOCK_STONE_PRESSURE_PLATE: + case E_BLOCK_BRICK: + case E_BLOCK_COBBLESTONE_STAIRS: + case E_BLOCK_COBBLESTONE_WALL: + case E_BLOCK_STONE_BRICK_STAIRS: + case E_BLOCK_NETHER_BRICK_STAIRS: + case E_BLOCK_CAULDRON: + case E_BLOCK_OBSIDIAN: + case E_BLOCK_DIAMOND_BLOCK: + case E_BLOCK_DIAMOND_ORE: + case E_BLOCK_GOLD_BLOCK: + case E_BLOCK_GOLD_ORE: + case E_BLOCK_REDSTONE_ORE: + case E_BLOCK_REDSTONE_ORE_GLOWING: + case E_BLOCK_EMERALD_ORE: + case E_BLOCK_IRON_BLOCK: + case E_BLOCK_IRON_ORE: + case E_BLOCK_LAPIS_ORE: + case E_BLOCK_LAPIS_BLOCK: + { + return false; + } + default: return true; + } } -- 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.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Items/ItemHandler.cpp') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index e256fa232..ec86648b3 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -335,7 +335,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const if (!cBlockInfo::IsOneHitDig(Block)) { - a_Player->UseEquippedItem(GetDurabilityLostWithThatAction(dlaBreakBlock)); + a_Player->UseEquippedItem(GetDurabilityLossByAction(dlaBreakBlock)); } } @@ -346,7 +346,7 @@ void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const void cItemHandler::OnEntityAttack(cPlayer * a_Attacker, cEntity * a_AttackedEntity) { UNUSED(a_AttackedEntity); - a_Attacker->UseEquippedItem(GetDurabilityLostWithThatAction(dlaAttackEntity)); + a_Attacker->UseEquippedItem(GetDurabilityLossByAction(dlaAttackEntity)); } @@ -364,7 +364,7 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I -short cItemHandler::GetDurabilityLostWithThatAction(eDurabilityLostAction a_Action) +short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action) { switch (a_Action) { -- cgit v1.2.3 From fd4ee20b2a927649b4671be95dccc8644c96e5ab Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Jul 2014 23:15:51 +0200 Subject: Hotfixed compilation problems. --- src/Items/ItemHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Items/ItemHandler.cpp') diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index ec86648b3..d36b5d663 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -366,7 +366,7 @@ void cItemHandler::OnFoodEaten(cWorld * a_World, cPlayer * a_Player, cItem * a_I short cItemHandler::GetDurabilityLossByAction(eDurabilityLostAction a_Action) { - switch (a_Action) + switch ((int)a_Action) { case dlaAttackEntity: return 2; case dlaBreakBlock: return 1; -- cgit v1.2.3