From cdc452916e3ec7e61f4a1ad822666192593b4b08 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Thu, 2 Apr 2020 12:42:15 +0000 Subject: Replace buckets to the selected hotbar slot, rather than the first available. (#4580) * Replace buckets to the selected hotbar slot, rather than the first available. Replicates vanilla behaviour, as well as being more logical. * Refactor cInventory::AddItem. Behaviour is now documented * Add new cInventory::ReplaceOneEquippedItem and ::SetEquippedItem methods * Return empty potion to the same slot after drinking * Replace buckets correctly in other situations, not simply water and lava Uses the new ReplaceOneEquippedItem method * Correct collecting water from source block with bottle * Add cPlayer::ReplaceOneEquippedItemTossRest method * Handle stacked filled buckets (in theory) Use new cPlayer::ReplaceOneEquippedItemTossRest method --- src/Entities/Player.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Entities/Player.h') 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); -- cgit v1.2.3