summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-04-22 00:16:28 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-07-06 21:56:05 +0200
commitf49f90906c76f4581b1caa225ee841fd60b1c04d (patch)
treec3d1720bb5e30b2f78c9c2d0e8ea3d1df940eaf4 /src
parentMade grass spreader prettier (diff)
downloadcuberite-f49f90906c76f4581b1caa225ee841fd60b1c04d.tar
cuberite-f49f90906c76f4581b1caa225ee841fd60b1c04d.tar.gz
cuberite-f49f90906c76f4581b1caa225ee841fd60b1c04d.tar.bz2
cuberite-f49f90906c76f4581b1caa225ee841fd60b1c04d.tar.lz
cuberite-f49f90906c76f4581b1caa225ee841fd60b1c04d.tar.xz
cuberite-f49f90906c76f4581b1caa225ee841fd60b1c04d.tar.zst
cuberite-f49f90906c76f4581b1caa225ee841fd60b1c04d.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp4
-rw-r--r--src/Mobs/Monster.cpp10
-rw-r--r--src/Protocol/Protocol_1_9.cpp2
3 files changed, 12 insertions, 4 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 5c444f74a..ae468d25c 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -39,8 +39,8 @@ cEntity::cEntity(eEntityType a_EntityType, Vector3d a_Pos, double a_Width, doubl
m_MaxHealth(1),
m_AttachedTo(nullptr),
m_Attachee(nullptr),
- m_bDirtyHead(true),
- m_bDirtyOrientation(true),
+ m_bDirtyHead(false),
+ m_bDirtyOrientation(false),
m_bHasSentNoSpeed(true),
m_bOnGround(false),
m_Gravity(-9.81f),
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 75bda197f..1c3b3a45e 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -490,14 +490,22 @@ void cMonster::CalcLeashActions(std::chrono::milliseconds a_Dt)
void cMonster::SetPitchAndYawFromDestination(bool a_IsFollowingPath)
{
Vector3d BodyDistance;
- if (!a_IsFollowingPath && (GetTarget() != nullptr))
+ if (!a_IsFollowingPath)
{
+ if (GetTarget() == nullptr)
+ {
+ // Avoid dirtying head position when nothing will change
+ // Thus avoids creating unnecessary network traffic
+ return;
+ }
+
BodyDistance = GetTarget()->GetPosition() - GetPosition();
}
else
{
BodyDistance = m_NextWayPointPosition - GetPosition();
}
+
double BodyRotation, BodyPitch;
BodyDistance.Normalize();
VectorToEuler(BodyDistance.x, BodyDistance.y, BodyDistance.z, BodyRotation, BodyPitch);
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index dfa371a62..8327eaf40 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -446,8 +446,8 @@ void cProtocol_1_9_0::SendSpawnMob(const cMonster & a_Mob)
Pkt.WriteBEDouble(LastSentPos.x);
Pkt.WriteBEDouble(LastSentPos.y);
Pkt.WriteBEDouble(LastSentPos.z);
+ Pkt.WriteByteAngle(a_Mob.GetHeadYaw()); // Doesn't seem to be used
Pkt.WriteByteAngle(a_Mob.GetPitch());
- Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
Pkt.WriteByteAngle(a_Mob.GetYaw());
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedX() * 400));
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedY() * 400));