1
0

Attached entities can't enter portals (#4484)

* Attached entities can't enter portals

* Whitespace fixes
This commit is contained in:
Mat 2020-03-05 21:33:43 +02:00 committed by GitHub
parent d572ad7faf
commit 83a41c93e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -1349,6 +1349,12 @@ bool cEntity::DetectPortal()
return false;
}
if ((m_AttachedTo != nullptr) || (m_Attachee != nullptr))
{
// Don't let attached entities change worlds, like players riding a minecart
return false;
}
if (IsPlayer() && !(static_cast<cPlayer *>(this))->IsGameModeCreative() && (m_PortalCooldownData.m_TicksDelayed != 80))
{
// Delay teleportation for four seconds if the entity is a non-creative player
@ -1425,6 +1431,12 @@ bool cEntity::DetectPortal()
return false;
}
if ((m_AttachedTo != nullptr) || (m_Attachee != nullptr))
{
// Don't let attached entities change worlds, like players riding a minecart
return false;
}
// End portal in the end
if (GetWorld()->GetDimension() == dimEnd)
{
@ -1523,6 +1535,9 @@ void cEntity::DoMoveToWorld(const sWorldChangeInfo & a_WorldChangeInfo)
GetChunkX(), GetChunkZ()
);
// If entity is attached to another entity, detach, to prevent client side effects
Detach();
// Stop ticking, in preperation for detaching from this world.
SetIsTicking(false);

View File

@ -2029,6 +2029,9 @@ void cPlayer::DoMoveToWorld(const cEntity::sWorldChangeInfo & a_WorldChangeInfo)
// Stop all mobs from targeting this player
StopEveryoneFromTargetingMe();
// If player is attached to entity, detach, to prevent client side effects
Detach();
// Prevent further ticking in this world
SetIsTicking(false);