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/Items/ItemBottle.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Items/ItemBottle.h') diff --git a/src/Items/ItemBottle.h b/src/Items/ItemBottle.h index b261937e5..18767dcde 100644 --- a/src/Items/ItemBottle.h +++ b/src/Items/ItemBottle.h @@ -83,8 +83,11 @@ public: return false; // Nothing in range. } - a_Player->GetInventory().RemoveOneEquippedItem(); - a_Player->GetInventory().AddItem(cItem(E_ITEM_POTION)); + // Give back a filled water bottle if gamemode is not creative: + if (!a_Player->IsGameModeCreative()) + { + a_Player->ReplaceOneEquippedItemTossRest(cItem(E_ITEM_POTION)); + } return true; } } ; -- cgit v1.2.3