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/BlockMobHead.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 'src/Blocks/BlockMobHead.h')
-rw-r--r-- | src/Blocks/BlockMobHead.h | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h index 764cd7f65..cdee5c297 100644 --- a/src/Blocks/BlockMobHead.h +++ b/src/Blocks/BlockMobHead.h @@ -11,53 +11,32 @@ class cBlockMobHeadHandler : public cBlockEntityHandler { + using super = cBlockEntityHandler; + public: cBlockMobHeadHandler(BLOCKTYPE a_BlockType): - cBlockEntityHandler(a_BlockType) + super(a_BlockType) { } - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override - { - // The drop spawn is in the OnDestroyedByPlayer method - } - virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override + + + + virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override { - if (a_Player.IsGameModeCreative()) + if ((a_BlockEntity == nullptr) || (a_BlockEntity->GetBlockType() != E_BLOCK_HEAD)) { - // No drops in creative mode - return; + return {}; } - - a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, [](cBlockEntity & a_BlockEntity) - { - if (a_BlockEntity.GetBlockType() != E_BLOCK_HEAD) - { - return false; - } - auto & MobHeadEntity = static_cast<cMobHeadEntity&>(a_BlockEntity); - - cItems Pickups; - Pickups.Add(E_ITEM_HEAD, 1, static_cast<short>(MobHeadEntity.GetType())); - auto & r1 = GetRandomProvider(); - - // Mid-block position first - double MicroX, MicroY, MicroZ; - MicroX = MobHeadEntity.GetPosX() + 0.5; - MicroY = MobHeadEntity.GetPosY() + 0.5; - MicroZ = MobHeadEntity.GetPosZ() + 0.5; - - // Add random offset second - MicroX += r1.RandReal<double>(-0.5, 0.5); - MicroZ += r1.RandReal<double>(-0.5, 0.5); - - MobHeadEntity.GetWorld()->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ); - return false; - } - ); + auto mobHeadEntity = static_cast<cMobHeadEntity *>(a_BlockEntity); + return cItem(E_ITEM_HEAD, 1, static_cast<short>(mobHeadEntity->GetType())); } + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); |