diff options
author | Mattes D <github@xoft.cz> | 2014-01-15 11:42:24 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-01-15 11:42:24 +0100 |
commit | 457e93f1edcd59d6110ea4c1ad4215438b656ea0 (patch) | |
tree | cb483c46f3d1ff3da6467ec867388041c038416f /src/Entities/Player.cpp | |
parent | Updated GETTING-STARTED.md to remove completed issues (diff) | |
parent | Yes newline at end of file :D (diff) | |
download | cuberite-457e93f1edcd59d6110ea4c1ad4215438b656ea0.tar cuberite-457e93f1edcd59d6110ea4c1ad4215438b656ea0.tar.gz cuberite-457e93f1edcd59d6110ea4c1ad4215438b656ea0.tar.bz2 cuberite-457e93f1edcd59d6110ea4c1ad4215438b656ea0.tar.lz cuberite-457e93f1edcd59d6110ea4c1ad4215438b656ea0.tar.xz cuberite-457e93f1edcd59d6110ea4c1ad4215438b656ea0.tar.zst cuberite-457e93f1edcd59d6110ea4c1ad4215438b656ea0.zip |
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r-- | src/Entities/Player.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index bc92790aa..fa6422389 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1884,3 +1884,33 @@ void cPlayer::ApplyFoodExhaustionFromMovement() + +void cPlayer::Detach() +{ + super::Detach(); + int PosX = (int)floor(GetPosX()); + int PosY = (int)floor(GetPosY()); + int PosZ = (int)floor(GetPosZ()); + + // Search for a position within an area to teleport player after detachment + // Position must be solid land, and occupied by a nonsolid block + // If nothing found, player remains where they are + for (int x = PosX - 2; x <= (PosX + 2); ++x) + { + for (int y = PosY; y <= (PosY + 3); ++y) + { + for (int z = PosZ - 2; z <= (PosZ + 2); ++z) + { + if (!g_BlockIsSolid[m_World->GetBlock(x, y, z)] && g_BlockIsSolid[m_World->GetBlock(x, y - 1, z)]) + { + TeleportToCoords(x, y, z); + return; + } + } + } + } +} + + + + |