summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-09-05 17:13:44 +0200
committerGitHub <noreply@github.com>2020-09-05 17:13:44 +0200
commitc2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd (patch)
treed87a9a2041afd755cbe0b63bb52e079b0f36235f /src/Mobs
parentUse pitch lookup in noteblock block entity (#4826) (diff)
downloadcuberite-c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd.tar
cuberite-c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd.tar.gz
cuberite-c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd.tar.bz2
cuberite-c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd.tar.lz
cuberite-c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd.tar.xz
cuberite-c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd.tar.zst
cuberite-c2f8ceb554982a33bcd4a1e168f6c4e26d0b85dd.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/PassiveMonster.cpp12
-rw-r--r--src/Mobs/PassiveMonster.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index f9d5e4ba4..1a8aaa3bf 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -57,6 +57,7 @@ void cPassiveMonster::ResetLoveMode()
m_LoveTimer = 0;
m_MatingTimer = 0;
m_LoveCooldown = 20 * 60 * 5; // 5 minutes
+ m_Feeder = cUUID();
// when an animal is in love mode, the client only stops sending the hearts if we let them know it's in cooldown, which is done with the "age" metadata
m_World->BroadcastEntityMetadata(*this);
@@ -125,6 +126,15 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
m_World->SpawnExperienceOrb(Pos.x, Pos.y, Pos.z, GetRandomProvider().RandInt(1, 6));
+ m_World->DoWithPlayerByUUID(m_Feeder, [&] (cPlayer & a_Player)
+ {
+ a_Player.GetStatManager().AddValue(Statistic::AnimalsBred);
+ if (GetMobType() == eMonsterType::mtCow)
+ {
+ a_Player.AwardAchievement(Statistic::AchBreedCow);
+ }
+ return true;
+ });
m_LovePartner->ResetLoveMode();
ResetLoveMode();
}
@@ -241,6 +251,8 @@ void cPassiveMonster::OnRightClicked(cPlayer & a_Player)
}
}
}
+ // Stores feeder UUID for statistic tracking
+ m_Feeder = a_Player.GetUUID();
}
diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h
index fbe381955..67d7399d8 100644
--- a/src/Mobs/PassiveMonster.h
+++ b/src/Mobs/PassiveMonster.h
@@ -2,6 +2,7 @@
#pragma once
#include "Monster.h"
+#include "../UUID.h"
@@ -60,6 +61,9 @@ protected:
/** The monster's breeding partner. */
cPassiveMonster * m_LovePartner;
+ /** Remembers the player is was last fed by for statistics tracking */
+ cUUID m_Feeder;
+
/** If above 0, the monster is in love mode, and will breed if a nearby monster is also in love mode. Decrements by 1 per tick till reaching zero. */
int m_LoveTimer;