From b3d4e0fca665502b727f0088a3a20aac1b9ad073 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Tue, 3 May 2016 10:48:39 +0300 Subject: Fixed death on teleportation or leaving Minecart (#3181) --- src/Entities/Player.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index d131699d3..a5868b528 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2468,17 +2468,21 @@ void cPlayer::Detach() int PosZ = POSZ_TOINT; // Search for a position within an area to teleport player after detachment - // Position must be solid land, and occupied by a nonsolid block + // Position must be solid land with two air blocks above. // If nothing found, player remains where they are - for (int x = PosX - 2; x <= (PosX + 2); ++x) + for (int x = PosX - 1; x <= (PosX + 1); ++x) { for (int y = PosY; y <= (PosY + 3); ++y) { - for (int z = PosZ - 2; z <= (PosZ + 2); ++z) + for (int z = PosZ - 1; z <= (PosZ + 1); ++z) { - if (!cBlockInfo::IsSolid(m_World->GetBlock(x, y, z)) && cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z))) + if ( + (m_World->GetBlock(x, y, z) == E_BLOCK_AIR) && + (m_World->GetBlock(x, y + 1, z) == E_BLOCK_AIR) && + cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z)) + ) { - TeleportToCoords(x, y, z); + TeleportToCoords(x + 0.5, y, z + 0.5); return; } } -- cgit v1.2.3