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
This commit is contained in:
committed by
GitHub
parent
d5c58c6b17
commit
cdc452916e
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user