diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-10-07 18:21:39 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-10-07 18:21:39 +0200 |
commit | a5e09155c0188472592fe40a46c17b8bdd330ac3 (patch) | |
tree | 9884755eb0a30b7bcd26051a093bf6d83a4e885b /src/Items | |
parent | Corrected IsBlockAttachable() in BlockVine.h (diff) | |
download | cuberite-a5e09155c0188472592fe40a46c17b8bdd330ac3.tar cuberite-a5e09155c0188472592fe40a46c17b8bdd330ac3.tar.gz cuberite-a5e09155c0188472592fe40a46c17b8bdd330ac3.tar.bz2 cuberite-a5e09155c0188472592fe40a46c17b8bdd330ac3.tar.lz cuberite-a5e09155c0188472592fe40a46c17b8bdd330ac3.tar.xz cuberite-a5e09155c0188472592fe40a46c17b8bdd330ac3.tar.zst cuberite-a5e09155c0188472592fe40a46c17b8bdd330ac3.zip |
Diffstat (limited to 'src/Items')
-rw-r--r-- | src/Items/ItemHandler.cpp | 4 | ||||
-rw-r--r-- | src/Items/ItemShears.h | 42 |
2 files changed, 35 insertions, 11 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 912dde022..9f6a751ef 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: @@ -587,6 +589,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) case E_BLOCK_IRON_TRAPDOOR: case E_BLOCK_LAPIS_BLOCK: case E_BLOCK_LAPIS_ORE: + case E_BLOCK_LEAVES: case E_BLOCK_LIT_FURNACE: case E_BLOCK_MOB_SPAWNER: case E_BLOCK_MOSSY_COBBLESTONE: @@ -594,6 +597,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) case E_BLOCK_NETHER_BRICK_STAIRS: case E_BLOCK_NETHER_BRICK_FENCE: case E_BLOCK_NETHERRACK: + case E_BLOCK_NEW_LEAVES: case E_BLOCK_NEW_STONE_SLAB: case E_BLOCK_OBSIDIAN: case E_BLOCK_PACKED_ICE: diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h index fa2794df2..e0c5c6623 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,30 @@ 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)) + if ((Block == E_BLOCK_TALL_GRASS) && !a_Player->IsGameModeCreative()) { + cItems Drops; + Drops.Add(Block, 1, BlockMeta); + a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ); a_Player->UseEquippedItem(); + return; + } + + super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ); + switch (Block) + { + case E_BLOCK_COBWEB: + case E_BLOCK_DEAD_BUSH: + case E_BLOCK_TRIPWIRE: + case E_BLOCK_VINES: + case E_BLOCK_WOOL: + { + a_Player->UseEquippedItem(); + } } } } ; |