summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-23 08:40:39 +0200
committerMattes D <github@xoft.cz>2014-10-23 08:40:39 +0200
commitf8c54f4243049abbcafff1e96f994f742ea9f50d (patch)
tree67fe10bfea90cbb21952039bd795666682d43ad5 /src/Items
parentCompile fix? (diff)
parentMerge pull request #1559 from mc-server/nullptr (diff)
downloadcuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.gz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.bz2
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.lz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.xz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.zst
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.zip
Diffstat (limited to 'src/Items')
-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 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();
+ }
}
}
} ;