summaryrefslogtreecommitdiffstats
path: root/src/Mobs/PassiveMonster.cpp
diff options
context:
space:
mode:
authorGargaj <gargaj@conspiracy.hu>2015-12-12 20:55:58 +0100
committerGargaj <gargaj@conspiracy.hu>2015-12-13 13:04:18 +0100
commit0eb519b35add5b8ac9553ed4716430fbd26b660e (patch)
tree1853aaa787b482c9d12e9de6ce40d84772b7527a /src/Mobs/PassiveMonster.cpp
parentMerge pull request #2741 from SafwatHalaby/mTarget2 (diff)
downloadcuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar
cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.gz
cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.bz2
cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.lz
cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.xz
cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.zst
cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/PassiveMonster.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index b700c0c5d..30b46500d 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -92,7 +92,26 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// Mating finished. Spawn baby
Vector3f Pos = (GetPosition() + m_LovePartner->GetPosition()) * 0.5;
- m_World->SpawnMob(Pos.x, Pos.y, Pos.z, GetMobType(), true);
+ UInt32 BabyID = m_World->SpawnMob(Pos.x, Pos.y, Pos.z, GetMobType(), true);
+
+ class cBabyInheritCallback :
+ public cEntityCallback
+ {
+ public:
+ cPassiveMonster * Baby;
+ cBabyInheritCallback() : Baby(nullptr) { }
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ Baby = static_cast<cPassiveMonster *>(a_Entity);
+ return true;
+ }
+ } Callback;
+
+ m_World->DoWithEntityByID(BabyID, Callback);
+ if (Callback.Baby != nullptr)
+ {
+ Callback.Baby->InheritFromParents(this, m_LovePartner);
+ }
cFastRandom Random;
m_World->SpawnExperienceOrb(Pos.x, Pos.y, Pos.z, 1 + Random.NextInt(6));