summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2020-04-02 14:42:15 +0200
committerGitHub <noreply@github.com>2020-04-02 14:42:15 +0200
commitcdc452916e3ec7e61f4a1ad822666192593b4b08 (patch)
treefcf35adfb6f907b7c2cd4388facc551cfe6c684a /src/Entities
parentTweak attack ranges (diff)
downloadcuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar
cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.gz
cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.bz2
cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.lz
cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.xz
cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.tar.zst
cuberite-cdc452916e3ec7e61f4a1ad822666192593b4b08.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Player.cpp19
-rw-r--r--src/Entities/Player.h7
2 files changed, 26 insertions, 0 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index b5d7f7c83..02cb7378d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1959,6 +1959,25 @@ void cPlayer::TossEquippedItem(char a_Amount)
+void cPlayer::ReplaceOneEquippedItemTossRest(const cItem & a_Item)
+{
+ auto PlacedCount = GetInventory().ReplaceOneEquippedItem(a_Item);
+ char ItemCountToToss = a_Item.m_ItemCount - static_cast<char>(PlacedCount);
+
+ if (ItemCountToToss == 0)
+ {
+ return;
+ }
+
+ cItem Pickup = a_Item;
+ Pickup.m_ItemCount = ItemCountToToss;
+ TossPickup(Pickup);
+}
+
+
+
+
+
void cPlayer::TossHeldItem(char a_Amount)
{
cItems Drops;
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index fafdd04eb..3ba87f748 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -313,6 +313,13 @@ public:
/** tosses the item in the selected hotbar slot */
void TossEquippedItem(char a_Amount = 1);
+ /** Removes one item from the the current equipped item stack, and attempts to add the specified item stack
+ back to the same slot. If it is not possible to place the item in the same slot, tries to place the specified
+ item elsewhere in the inventory. If this is not possible, then any remaining items are tossed. If the currently
+ equipped slot is empty, its contents are simply set to the given Item.
+ */
+ void ReplaceOneEquippedItemTossRest(const cItem &);
+
/** tosses the item held in hand (when in UI windows) */
void TossHeldItem(char a_Amount = 1);