summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-05-04 10:10:47 +0200
committerGitHub <noreply@github.com>2020-05-04 10:10:47 +0200
commit07ca09574072b303064eafb2751f8f83c865f083 (patch)
treea863831747b046c143a3e2d09ad1f665501d9a0d /src/Entities/Player.cpp
parentButtons can now be triggered by arrows. (#4670) (diff)
downloadcuberite-07ca09574072b303064eafb2751f8f83c865f083.tar
cuberite-07ca09574072b303064eafb2751f8f83c865f083.tar.gz
cuberite-07ca09574072b303064eafb2751f8f83c865f083.tar.bz2
cuberite-07ca09574072b303064eafb2751f8f83c865f083.tar.lz
cuberite-07ca09574072b303064eafb2751f8f83c865f083.tar.xz
cuberite-07ca09574072b303064eafb2751f8f83c865f083.tar.zst
cuberite-07ca09574072b303064eafb2751f8f83c865f083.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 46a1606d0..3f2ab21c1 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -681,6 +681,24 @@ void cPlayer::AddFoodExhaustion(double a_Exhaustion)
+void cPlayer::TossItems(const cItems & a_Items)
+{
+ if (IsGameModeSpectator()) // Players can't toss items in spectator
+ {
+ return;
+ }
+
+ m_Stats.AddValue(statItemsDropped, static_cast<StatValue>(a_Items.Size()));
+
+ const auto Speed = (GetLookVector() + Vector3d(0, 0.2, 0)) * 6; // A dash of height and a dollop of speed
+ const auto Position = GetEyePosition() - Vector3d(0, 0.2, 0); // Correct for eye-height weirdness
+ m_World->SpawnItemPickups(a_Items, Position, Speed, true); // 'true' because created by player
+}
+
+
+
+
+
void cPlayer::StartEating(void)
{
// Set the timer:
@@ -1647,11 +1665,10 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
// ask plugins to allow teleport to the new position.
if (!cRoot::Get()->GetPluginManager()->CallHookEntityTeleport(*this, m_LastPosition, Vector3d(a_PosX, a_PosY, a_PosZ)))
{
- ResetPosition({a_PosX, a_PosY, a_PosZ});
+ SetPosition({a_PosX, a_PosY, a_PosZ});
FreezeInternal(GetPosition(), false);
m_bIsTeleporting = true;
- m_World->BroadcastTeleportEntity(*this, GetClientHandle());
m_ClientHandle->SendPlayerMoveLook();
}
}
@@ -2017,25 +2034,6 @@ void cPlayer::TossPickup(const cItem & a_Item)
-void cPlayer::TossItems(const cItems & a_Items)
-{
- if (IsGameModeSpectator()) // Players can't toss items in spectator
- {
- return;
- }
-
- m_Stats.AddValue(statItemsDropped, static_cast<StatValue>(a_Items.Size()));
-
- double vX = 0, vY = 0, vZ = 0;
- EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY);
- vY = -vY * 2 + 1.f;
- m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player
-}
-
-
-
-
-
void cPlayer::DoMoveToWorld(const cEntity::sWorldChangeInfo & a_WorldChangeInfo)
{
ASSERT(a_WorldChangeInfo.m_NewWorld != nullptr);