summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-19 14:55:22 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-01-19 14:55:22 +0100
commit82b2290b74519ab86d6abae463cbe0c1d8ac5868 (patch)
tree98855d56f18990731d88c283c6990d98b3d26245 /src/Entities/Player.cpp
parentMinecart collision and general improvements (diff)
parentUpdated core (diff)
downloadcuberite-82b2290b74519ab86d6abae463cbe0c1d8ac5868.tar
cuberite-82b2290b74519ab86d6abae463cbe0c1d8ac5868.tar.gz
cuberite-82b2290b74519ab86d6abae463cbe0c1d8ac5868.tar.bz2
cuberite-82b2290b74519ab86d6abae463cbe0c1d8ac5868.tar.lz
cuberite-82b2290b74519ab86d6abae463cbe0c1d8ac5868.tar.xz
cuberite-82b2290b74519ab86d6abae463cbe0c1d8ac5868.tar.zst
cuberite-82b2290b74519ab86d6abae463cbe0c1d8ac5868.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index fa6422389..c1f2456eb 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1382,16 +1382,21 @@ void cPlayer::TossItem(
cItem DroppedItem(GetInventory().GetEquippedItem());
if (!DroppedItem.IsEmpty())
{
- if (GetInventory().RemoveOneEquippedItem())
+ char NewAmount = a_Amount;
+ if (NewAmount > GetInventory().GetEquippedItem().m_ItemCount)
{
- DroppedItem.m_ItemCount = 1; // RemoveItem decreases the count, so set it to 1 again
- Drops.push_back(DroppedItem);
+ NewAmount = GetInventory().GetEquippedItem().m_ItemCount; // Drop only what's there
}
+
+ GetInventory().GetHotbarGrid().ChangeSlotCount(GetInventory().GetEquippedSlotNum() /* Returns hotbar subslot, which HotbarGrid takes */, -a_Amount);
+
+ DroppedItem.m_ItemCount = NewAmount;
+ Drops.push_back(DroppedItem);
}
}
}
double vX = 0, vY = 0, vZ = 0;
- EulerToVector(-GetRotation(), GetPitch(), vZ, vX, vY);
+ EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY);
vY = -vY * 2 + 1.f;
m_World->SpawnItemPickups(Drops, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player
}
@@ -1523,7 +1528,7 @@ bool cPlayer::LoadFromDisk()
Json::Value & JSON_PlayerRotation = root["rotation"];
if (JSON_PlayerRotation.size() == 3)
{
- SetRotation ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
+ SetYaw ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());
SetPitch ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());
SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
}
@@ -1586,7 +1591,7 @@ bool cPlayer::SaveToDisk()
JSON_PlayerPosition.append(Json::Value(GetPosZ()));
Json::Value JSON_PlayerRotation;
- JSON_PlayerRotation.append(Json::Value(GetRotation()));
+ JSON_PlayerRotation.append(Json::Value(GetYaw()));
JSON_PlayerRotation.append(Json::Value(GetPitch()));
JSON_PlayerRotation.append(Json::Value(GetRoll()));