diff options
Diffstat (limited to 'src/Items')
-rw-r--r-- | src/Items/ItemHandler.cpp | 2 | ||||
-rw-r--r-- | src/Items/ItemShears.h | 35 |
2 files changed, 25 insertions, 12 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index d1588e9d8..9272a723d 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -572,6 +572,8 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) case E_BLOCK_COBBLESTONE: case E_BLOCK_COBBLESTONE_STAIRS: case E_BLOCK_COBBLESTONE_WALL: + case E_BLOCK_COBWEB: + case E_BLOCK_DEAD_BUSH: case E_BLOCK_DIAMOND_BLOCK: case E_BLOCK_DIAMOND_ORE: case E_BLOCK_DOUBLE_NEW_STONE_SLAB: diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h index fa2794df2..73343f629 100644 --- a/src/Items/ItemShears.h +++ b/src/Items/ItemShears.h @@ -28,21 +28,25 @@ public: virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override { - BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + BLOCKTYPE Block; + NIBBLETYPE BlockMeta; + a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, BlockMeta); + if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES)) { - NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); + cItems Drops; cBlockHandler * Handler = cBlockInfo::GetHandler(Block); - cItems Drops; - Handler->ConvertToPickups(Drops, Meta); - Drops.push_back(cItem(Block, 1, Meta & 3)); + Handler->ConvertToPickups(Drops, BlockMeta); + Drops.Add(Block, 1, BlockMeta & 3); a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ); a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ); a_Player->UseEquippedItem(); return true; } + return false; } @@ -53,12 +57,10 @@ public: { case E_BLOCK_COBWEB: case E_BLOCK_VINES: - case E_BLOCK_LEAVES: - case E_BLOCK_NEW_LEAVES: { return true; } - } // switch (a_BlockType) + } return super::CanHarvestBlock(a_BlockType); } @@ -71,12 +73,21 @@ public: virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ) override { - super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ); + BLOCKTYPE Block; + NIBBLETYPE BlockMeta; + a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, BlockMeta); - BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - if ((Block == E_BLOCK_TRIPWIRE) || (Block == E_BLOCK_VINES)) + super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ); + switch (Block) { - a_Player->UseEquippedItem(); + case E_BLOCK_COBWEB: + case E_BLOCK_DEAD_BUSH: + case E_BLOCK_TRIPWIRE: + case E_BLOCK_VINES: + case E_BLOCK_WOOL: + { + a_Player->UseEquippedItem(); + } } } } ; |