summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorMat <mail@mathias.is>2020-03-30 21:35:37 +0200
committerGitHub <noreply@github.com>2020-03-30 21:35:37 +0200
commit5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81 (patch)
tree5c887139d79edcfb97af78c6575ec3de23bb3051 /src/Entities/Player.cpp
parentSend experience on respawn (#4586) (diff)
downloadcuberite-5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81.tar
cuberite-5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81.tar.gz
cuberite-5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81.tar.bz2
cuberite-5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81.tar.lz
cuberite-5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81.tar.xz
cuberite-5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81.tar.zst
cuberite-5eb1ba3bcc3983f936ef1d0a7701f19152d0dd81.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 396069f0a..8876566da 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1703,6 +1703,23 @@ void cPlayer::SendRotation(double a_YawDegrees, double a_PitchDegrees)
+void cPlayer::SpectateEntity(cEntity * a_Target)
+{
+ if ((a_Target == nullptr) || (static_cast<cEntity *>(this) == a_Target))
+ {
+ GetClientHandle()->SendCameraSetTo(*this);
+ m_AttachedTo = nullptr;
+ return;
+ }
+
+ m_AttachedTo = a_Target;
+ GetClientHandle()->SendCameraSetTo(*m_AttachedTo);
+}
+
+
+
+
+
Vector3d cPlayer::GetThrowStartPos(void) const
{
Vector3d res = GetEyePosition();
@@ -2838,8 +2855,7 @@ void cPlayer::AttachTo(cEntity * a_AttachTo)
// Different attach, if this is a spectator
if (IsGameModeSpectator())
{
- m_AttachedTo = a_AttachTo;
- GetClientHandle()->SendCameraSetTo(*m_AttachedTo);
+ SpectateEntity(a_AttachTo);
return;
}