summaryrefslogtreecommitdiffstats
path: root/src/Mobs/PassiveMonster.cpp
diff options
context:
space:
mode:
authorSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-13 13:12:25 +0100
committerSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-13 13:12:25 +0100
commit4a212777cbda77e87b22ad312557aa4b6331f429 (patch)
tree1853aaa787b482c9d12e9de6ce40d84772b7527a /src/Mobs/PassiveMonster.cpp
parentMerge pull request #2741 from SafwatHalaby/mTarget2 (diff)
parentsheep color inheritance (diff)
downloadcuberite-4a212777cbda77e87b22ad312557aa4b6331f429.tar
cuberite-4a212777cbda77e87b22ad312557aa4b6331f429.tar.gz
cuberite-4a212777cbda77e87b22ad312557aa4b6331f429.tar.bz2
cuberite-4a212777cbda77e87b22ad312557aa4b6331f429.tar.lz
cuberite-4a212777cbda77e87b22ad312557aa4b6331f429.tar.xz
cuberite-4a212777cbda77e87b22ad312557aa4b6331f429.tar.zst
cuberite-4a212777cbda77e87b22ad312557aa4b6331f429.zip
Diffstat (limited to 'src/Mobs/PassiveMonster.cpp')
-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));