summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockMobHead.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks/BlockMobHead.h')
-rw-r--r--src/Blocks/BlockMobHead.h51
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);