summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemShears.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-10-07 18:21:39 +0200
committerHowaner <franzi.moos@googlemail.com>2014-10-07 18:21:39 +0200
commita5e09155c0188472592fe40a46c17b8bdd330ac3 (patch)
tree9884755eb0a30b7bcd26051a093bf6d83a4e885b /src/Items/ItemShears.h
parentCorrected IsBlockAttachable() in BlockVine.h (diff)
downloadcuberite-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 '')
-rw-r--r--src/Items/ItemShears.h42
1 files changed, 31 insertions, 11 deletions
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();
+ }
}
}
} ;