summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate <nate@natedpalm.com>2021-04-08 12:17:24 +0200
committerGitHub <noreply@github.com>2021-04-08 12:17:24 +0200
commitb2eddbed84d55978337d1b52f6a9a2eabb658017 (patch)
treea5d82669cf41867c5eec12542ed71f74c4056374
parentChange to Cuboid calculation for splash distance (#5176) (diff)
downloadcuberite-b2eddbed84d55978337d1b52f6a9a2eabb658017.tar
cuberite-b2eddbed84d55978337d1b52f6a9a2eabb658017.tar.gz
cuberite-b2eddbed84d55978337d1b52f6a9a2eabb658017.tar.bz2
cuberite-b2eddbed84d55978337d1b52f6a9a2eabb658017.tar.lz
cuberite-b2eddbed84d55978337d1b52f6a9a2eabb658017.tar.xz
cuberite-b2eddbed84d55978337d1b52f6a9a2eabb658017.tar.zst
cuberite-b2eddbed84d55978337d1b52f6a9a2eabb658017.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp16
-rw-r--r--src/Entities/Player.h1
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp24
3 files changed, 38 insertions, 3 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index a727429d4..d9c51fcef 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2591,6 +2591,15 @@ void cPlayer::AttachTo(cEntity * a_AttachTo)
void cPlayer::Detach()
{
+ Detach(false);
+}
+
+
+
+
+
+void cPlayer::Detach(bool a_IsTeleporting)
+{
if (m_AttachedTo == nullptr)
{
// The player is not attached to anything. Bail out.
@@ -2607,6 +2616,13 @@ void cPlayer::Detach()
}
Super::Detach();
+
+ // If they are teleporting, no need to figure out position
+ if (a_IsTeleporting)
+ {
+ return;
+ }
+
int PosX = POSX_TOINT;
int PosY = POSY_TOINT;
int PosZ = POSZ_TOINT;
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 5a17ca783..65dbfaed7 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -604,6 +604,7 @@ public:
// cEntity overrides:
virtual void AttachTo(cEntity * a_AttachTo) override;
virtual void Detach(void) override;
+ virtual void Detach(bool a_IsTeleporting);
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
virtual cItem GetEquippedHelmet(void) const override { return m_Inventory.GetEquippedHelmet(); }
virtual cItem GetEquippedChestplate(void) const override { return m_Inventory.GetEquippedChestplate(); }
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index 4f1029b27..ec4af7a7c 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -34,12 +34,29 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_Hi
void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
int TotalDamage = 0;
+
+ bool isAttachedEntity = GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, [& a_EntityHit](cPlayer & a_Entity)
+ {
+ const cEntity * attachedEntity = a_Entity.GetAttached();
+ if (attachedEntity == nullptr)
+ {
+ // nothing attached
+ return false;
+ }
+
+ return attachedEntity->GetUniqueID() == a_EntityHit.GetUniqueID();
+ }
+ );
// TODO: If entity is Ender Crystal, destroy it
- TeleportCreator(a_HitPos);
- a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
- m_DestroyTimer = 5;
+ if (!isAttachedEntity)
+ {
+ TeleportCreator(a_HitPos);
+ a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
+ m_DestroyTimer = 5;
+ }
+
}
@@ -79,6 +96,7 @@ void cThrownEnderPearlEntity::TeleportCreator(Vector3d a_HitPos)
// Teleport the creator here, make them take 5 damage:
a_Entity.TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z);
a_Entity.TakeDamage(dtEnderPearl, this, 5, 0);
+ a_Entity.Detach(true);
return true;
}
);