diff options
author | Mattes D <github@xoft.cz> | 2019-10-16 10:06:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-16 10:06:34 +0200 |
commit | 221cc4ec5cb6301743e947eaabed3fecedba796f (patch) | |
tree | 4e44c8bb7523e5d1d04468fc906ae24674c10abc /src/Blocks/BlockDeadBush.h | |
parent | Fixed crash in hopper while pulling items from blockentity above itself (#4412) (diff) | |
download | cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.gz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.bz2 cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.lz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.xz cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.tar.zst cuberite-221cc4ec5cb6301743e947eaabed3fecedba796f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockDeadBush.h | 61 |
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; } } ; - - - - |