Don't send entity velocity for boats (#4488)
* Don't send entity velocity for boats
This commit is contained in:
parent
83a41c93e9
commit
5a2163d7e6
@ -39,6 +39,35 @@ void cBoat::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
|
||||
|
||||
|
||||
void cBoat::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
|
||||
{
|
||||
// Process packet sending every two ticks
|
||||
if (GetWorld()->GetWorldAge() % 2 != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3i Diff = (GetPosition() * 32.0).Floor() - (m_LastSentPosition * 32.0).Floor();
|
||||
|
||||
if (Diff.HasNonZeroLength()) // Have we moved?
|
||||
{
|
||||
if ((abs(Diff.x) <= 127) && (abs(Diff.y) <= 127) && (abs(Diff.z) <= 127)) // Limitations of a Byte
|
||||
{
|
||||
m_World->BroadcastEntityRelMove(*this, Vector3<Int8>(Diff), a_Exclude);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Too big a movement, do a teleport
|
||||
m_World->BroadcastTeleportEntity(*this, a_Exclude);
|
||||
}
|
||||
m_LastSentPosition = GetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cBoat::DoTakeDamage(TakeDamageInfo & TDI)
|
||||
{
|
||||
m_LastDamage = 10;
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
|
||||
// cEntity overrides:
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = nullptr) override;
|
||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
|
||||
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||
|
@ -44,6 +44,7 @@ cEntity::cEntity(eEntityType a_EntityType, Vector3d a_Pos, double a_Width, doubl
|
||||
m_bOnGround(false),
|
||||
m_Gravity(-9.81f),
|
||||
m_AirDrag(0.02f),
|
||||
m_LastSentPosition(a_Pos),
|
||||
m_LastPosition(a_Pos),
|
||||
m_EntityType(a_EntityType),
|
||||
m_World(nullptr),
|
||||
@ -65,7 +66,6 @@ cEntity::cEntity(eEntityType a_EntityType, Vector3d a_Pos, double a_Width, doubl
|
||||
m_HeadYaw(0.0),
|
||||
m_Rot(0.0, 0.0, 0.0),
|
||||
m_Position(a_Pos),
|
||||
m_LastSentPosition(a_Pos),
|
||||
m_WaterSpeed(0, 0, 0),
|
||||
m_Mass (0.001), // Default 1g
|
||||
m_Width(a_Width),
|
||||
|
@ -656,6 +656,10 @@ protected:
|
||||
Data: https://minecraft.gamepedia.com/Entity#Motion_of_entities */
|
||||
float m_AirDrag;
|
||||
|
||||
/** Last position sent to client via the Relative Move or Teleport packets (not Velocity)
|
||||
Only updated if cEntity::BroadcastMovementUpdate() is called! */
|
||||
Vector3d m_LastSentPosition;
|
||||
|
||||
Vector3d m_LastPosition;
|
||||
|
||||
eEntityType m_EntityType;
|
||||
@ -752,10 +756,6 @@ private:
|
||||
/** Position of the entity's XZ center and Y bottom */
|
||||
Vector3d m_Position;
|
||||
|
||||
/** Last position sent to client via the Relative Move or Teleport packets (not Velocity)
|
||||
Only updated if cEntity::BroadcastMovementUpdate() is called! */
|
||||
Vector3d m_LastSentPosition;
|
||||
|
||||
/** Measured in meter / second */
|
||||
Vector3d m_WaterSpeed;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user