summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockDeadBush.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks/BlockDeadBush.h')
-rw-r--r--src/Blocks/BlockDeadBush.h61
1 files changed, 19 insertions, 42 deletions
diff --git a/src/Blocks/BlockDeadBush.h b/src/Blocks/BlockDeadBush.h
index 68846ff46..0b7d27e8b 100644
--- a/src/Blocks/BlockDeadBush.h
+++ b/src/Blocks/BlockDeadBush.h
@@ -43,57 +43,34 @@ public:
}
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Drop 0-3 sticks
- char chance = GetRandomProvider().RandInt<char>(3);
- if (chance != 0)
- {
- a_Pickups.emplace_back(E_ITEM_STICK, 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
+
+
+ virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
{
- if (a_CanDrop && (a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
+ // If cutting down with shears, drop self:
+ if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
{
- NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta({a_BlockX, a_BlockY, a_BlockZ});
- cItems Drops;
- Drops.Add(m_BlockType, 1, Meta);
+ return cItem(m_BlockType, 1, a_BlockMeta);
+ }
- // Allow plugins to modify the pickups:
- a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Drops);
+ // Drop 0-3 sticks:
+ auto chance = GetRandomProvider().RandInt<char>(3);
+ if (chance > 0)
+ {
+ return cItem(E_ITEM_STICK, chance, 0);
+ }
+ return {};
+ }
- // Spawn the pickups:
- if (!Drops.empty())
- {
- auto & r1 = GetRandomProvider();
- // 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.RandReal<double>(-0.5, 0.5);
- MicroZ += r1.RandReal<double>(-0.5, 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);
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 0;
}
} ;
-
-
-
-