summaryrefslogtreecommitdiffstats
path: root/src/Entities/Boat.cpp
diff options
context:
space:
mode:
authorMat <mail@mathias.is>2020-03-07 12:56:02 +0100
committerGitHub <noreply@github.com>2020-03-07 12:56:02 +0100
commit5a2163d7e6ffa0c5c568be41257fb726d452b3b9 (patch)
tree2ac35cb27db2216ff0f4a0874f0ad40f27b6a334 /src/Entities/Boat.cpp
parentAttached entities can't enter portals (#4484) (diff)
downloadcuberite-5a2163d7e6ffa0c5c568be41257fb726d452b3b9.tar
cuberite-5a2163d7e6ffa0c5c568be41257fb726d452b3b9.tar.gz
cuberite-5a2163d7e6ffa0c5c568be41257fb726d452b3b9.tar.bz2
cuberite-5a2163d7e6ffa0c5c568be41257fb726d452b3b9.tar.lz
cuberite-5a2163d7e6ffa0c5c568be41257fb726d452b3b9.tar.xz
cuberite-5a2163d7e6ffa0c5c568be41257fb726d452b3b9.tar.zst
cuberite-5a2163d7e6ffa0c5c568be41257fb726d452b3b9.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Boat.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index c88df4952..d0ac27228 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -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;