summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-06-01 00:50:35 +0200
committerHowaner <franzi.moos@googlemail.com>2014-06-01 00:50:35 +0200
commit12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8 (patch)
tree956d0f5a8d070d6d39e23641449ce6a4e4e6c99f
parentAdd HandleSmeltItem() call for achievements. (diff)
downloadcuberite-12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8.tar
cuberite-12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8.tar.gz
cuberite-12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8.tar.bz2
cuberite-12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8.tar.lz
cuberite-12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8.tar.xz
cuberite-12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8.tar.zst
cuberite-12f3c0fcdf6e45cbeed630730edb1223a2ecc4d8.zip
Diffstat (limited to '')
-rw-r--r--src/UI/SlotArea.cpp38
-rw-r--r--src/UI/SlotArea.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index ac85322b3..59a6384b1 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -1484,6 +1484,44 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
+void cSlotAreaFurnace::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
+{
+ for (int i = 0; i < 2; i++)
+ {
+ const cItem * Slot = GetSlot(i, a_Player);
+ if (!Slot->IsEqual(a_ItemStack) && (!Slot->IsEmpty() || a_KeepEmptySlots))
+ {
+ // Different items
+ continue;
+ }
+ int NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ if (NumFit <= 0)
+ {
+ // Full stack already
+ continue;
+ }
+ if (NumFit > a_ItemStack.m_ItemCount)
+ {
+ NumFit = a_ItemStack.m_ItemCount;
+ }
+ if (a_ShouldApply)
+ {
+ cItem NewSlot(a_ItemStack);
+ NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit;
+ SetSlot(i, a_Player, NewSlot);
+ }
+ a_ItemStack.m_ItemCount -= NumFit;
+ if (a_ItemStack.IsEmpty())
+ {
+ return;
+ }
+ } // for i - Slots
+}
+
+
+
+
+
const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
{
UNUSED(a_Player);
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index e297bcff7..b4b693cf6 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -392,6 +392,7 @@ public:
virtual ~cSlotAreaFurnace();
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
+ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;