From 83e18f6d31727d58d5bfa59b7e8fa0446443304a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 18 Dec 2020 20:44:06 +0000 Subject: Horsies: don't always broadcast metadata --- src/Mobs/Horse.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Mobs') 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(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); + } } -- cgit v1.2.3