summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Horse.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-12-18 21:44:06 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2020-12-18 21:44:06 +0100
commit83e18f6d31727d58d5bfa59b7e8fa0446443304a (patch)
tree7b3825168073c2309a8b9d5c8f30d24e6296f9de /src/Mobs/Horse.cpp
parentFixes incorrect var name in RsaPrivateKey.cpp (diff)
downloadcuberite-83e18f6d31727d58d5bfa59b7e8fa0446443304a.tar
cuberite-83e18f6d31727d58d5bfa59b7e8fa0446443304a.tar.gz
cuberite-83e18f6d31727d58d5bfa59b7e8fa0446443304a.tar.bz2
cuberite-83e18f6d31727d58d5bfa59b7e8fa0446443304a.tar.lz
cuberite-83e18f6d31727d58d5bfa59b7e8fa0446443304a.tar.xz
cuberite-83e18f6d31727d58d5bfa59b7e8fa0446443304a.tar.zst
cuberite-83e18f6d31727d58d5bfa59b7e8fa0446443304a.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Horse.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index 926f125b9..e42241700 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -54,12 +54,14 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
return;
}
+ bool MetadataDirty = false;
auto & Random = GetRandomProvider();
if (!m_bIsMouthOpen)
{
if (Random.RandBool(0.02))
{
+ MetadataDirty = true;
m_bIsMouthOpen = true;
}
}
@@ -67,6 +69,7 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (Random.RandBool(0.10))
{
+ MetadataDirty = true;
m_bIsMouthOpen = false;
}
}
@@ -84,12 +87,14 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
m_World->BroadcastSoundEffect("entity.horse.angry", GetPosition(), 1.0f, 1.0f);
m_Attachee->Detach();
+ MetadataDirty = true;
m_bIsRearing = true;
}
}
else
{
m_World->BroadcastParticleEffect("heart", static_cast<Vector3f>(GetPosition()), Vector3f{}, 0, 5);
+ MetadataDirty = true;
m_bIsTame = true;
}
}
@@ -98,6 +103,7 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_RearTickCount == 20)
{
+ MetadataDirty = true;
m_bIsRearing = false;
m_RearTickCount = 0;
}
@@ -107,7 +113,10 @@ void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
}
- m_World->BroadcastEntityMetadata(*this);
+ if (MetadataDirty)
+ {
+ m_World->BroadcastEntityMetadata(*this);
+ }
}