summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CONTRIBUTORS1
-rw-r--r--src/Blocks/BlockDeadBush.h46
-rw-r--r--src/Blocks/BlockHandler.cpp1
-rw-r--r--src/Items/ItemHandler.cpp1
-rw-r--r--src/Items/ItemShears.h1
5 files changed, 49 insertions, 1 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 84186be46..0cf95af2a 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -6,6 +6,7 @@ bearbin (Alexander Harkness)
beeduck
bibo38
birkett (Anthony Birkett)
+Bond_009
derouinw
Diusrex
Duralex
diff --git a/src/Blocks/BlockDeadBush.h b/src/Blocks/BlockDeadBush.h
index b86e3557e..9afa2d323 100644
--- a/src/Blocks/BlockDeadBush.h
+++ b/src/Blocks/BlockDeadBush.h
@@ -10,6 +10,7 @@
class cBlockDeadBushHandler :
public cBlockHandler
{
+ typedef cBlockHandler super;
public:
cBlockDeadBushHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
@@ -37,11 +38,56 @@ public:
}
}
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ // Drop 0-3 sticks
+ cFastRandom random;
+ int chance = random.NextInt(3);
+ if (chance != 0)
+ {
+ a_Pickups.push_back(cItem(E_ITEM_STICK, static_cast<char>(chance), 0));
+ }
+ }
+
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
+
+ virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override
+ {
+ if (a_CanDrop && (a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
+ {
+ NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ cItems Drops;
+ Drops.Add(m_BlockType, 1, Meta);
+
+ // Allow plugins to modify the pickups:
+ a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Drops);
+
+ // Spawn the pickups:
+ if (!Drops.empty())
+ {
+ MTRand r1;
+
+ // Mid-block position first
+ double MicroX, MicroY, MicroZ;
+ MicroX = a_BlockX + 0.5;
+ MicroY = a_BlockY + 0.5;
+ MicroZ = a_BlockZ + 0.5;
+
+ // Add random offset second
+ MicroX += r1.rand(1) - 0.5;
+ MicroZ += r1.rand(1) - 0.5;
+
+ a_WorldInterface.SpawnItemPickups(Drops, MicroX, MicroY, MicroZ);
+ }
+ return;
+ }
+
+ super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop);
+ }
} ;
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 028fdbfbd..687824066 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -473,6 +473,7 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
case E_BLOCK_COCOA_POD:
case E_BLOCK_CROPS:
case E_BLOCK_DARK_OAK_DOOR:
+ case E_BLOCK_DEAD_BUSH:
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB:
case E_BLOCK_DOUBLE_STONE_SLAB:
case E_BLOCK_DOUBLE_WOODEN_SLAB:
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index d05364e95..d037092b1 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -745,7 +745,6 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
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_RED_SANDSTONE_SLAB:
diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h
index db5e10c7e..47e58ae4b 100644
--- a/src/Items/ItemShears.h
+++ b/src/Items/ItemShears.h
@@ -56,6 +56,7 @@ public:
switch (a_BlockType)
{
case E_BLOCK_COBWEB:
+ case E_BLOCK_DEAD_BUSH:
case E_BLOCK_VINES:
{
return true;