summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-21 22:04:51 +0200
committerMattes D <github@xoft.cz>2014-10-21 22:04:51 +0200
commit814e4404bb428a0d825f12e513562d4e43e9e6dc (patch)
tree6916feb703428abc5d4788db2c67c47e9da10905 /src/Items
parentProperly exported cItemFrame and cHangingEntity to Lua. (diff)
parentReverted hook move. (diff)
downloadcuberite-814e4404bb428a0d825f12e513562d4e43e9e6dc.tar
cuberite-814e4404bb428a0d825f12e513562d4e43e9e6dc.tar.gz
cuberite-814e4404bb428a0d825f12e513562d4e43e9e6dc.tar.bz2
cuberite-814e4404bb428a0d825f12e513562d4e43e9e6dc.tar.lz
cuberite-814e4404bb428a0d825f12e513562d4e43e9e6dc.tar.xz
cuberite-814e4404bb428a0d825f12e513562d4e43e9e6dc.tar.zst
cuberite-814e4404bb428a0d825f12e513562d4e43e9e6dc.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemHandler.cpp2
-rw-r--r--src/Items/ItemShears.h35
2 files changed, 25 insertions, 12 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 912dde022..f1f1ddcc5 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();
+ }
}
}
} ;