summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate <palmern22@gmail.com>2018-08-17 10:08:06 +0200
committerpeterbell10 <peterbell10@live.co.uk>2018-08-17 10:08:06 +0200
commite7b552603f760ab2f7868b3fa4d73e3ee6158dbf (patch)
treea2342a1762975c2f2be58e82dddf18d2a06b00c0
parentFix: Create players folder recursively (#4283) (diff)
downloadcuberite-e7b552603f760ab2f7868b3fa4d73e3ee6158dbf.tar
cuberite-e7b552603f760ab2f7868b3fa4d73e3ee6158dbf.tar.gz
cuberite-e7b552603f760ab2f7868b3fa4d73e3ee6158dbf.tar.bz2
cuberite-e7b552603f760ab2f7868b3fa4d73e3ee6158dbf.tar.lz
cuberite-e7b552603f760ab2f7868b3fa4d73e3ee6158dbf.tar.xz
cuberite-e7b552603f760ab2f7868b3fa4d73e3ee6158dbf.tar.zst
cuberite-e7b552603f760ab2f7868b3fa4d73e3ee6158dbf.zip
-rw-r--r--src/UI/SlotArea.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 0c69e33b0..e3c9bf5e8 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -1482,7 +1482,21 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio
bAsync = true;
}
cItem & DraggingItem = a_Player.GetDraggingItem();
+ if (a_SlotNum == 1)
+ {
+ // Lapis slot can have a full stack handle it normally, also check for empty hand
+ if ((DraggingItem.IsEmpty()) || ((DraggingItem.m_ItemType == E_ITEM_DYE) && (DraggingItem.m_ItemDamage == E_META_DYE_BLUE)))
+ {
+ return cSlotArea::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
+ }
+ if (bAsync)
+ {
+ m_ParentWindow.BroadcastWholeWindow();
+ }
+ return;
+ }
+ // Slot 0 is where the item to enhance goes.
if (DraggingItem.IsEmpty())
{
// DraggingItem is empty -> Switch draggingitem and slot
@@ -1521,6 +1535,28 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio
void cSlotAreaEnchanting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_Apply, bool a_KeepEmptySlots, bool a_BackFill)
{
+ if ((a_ItemStack.m_ItemType == E_ITEM_DYE) && (a_ItemStack.m_ItemDamage == E_META_DYE_BLUE))
+ {
+ // It's lapis, put it in the lapis spot.
+ const cItem * Slot = GetSlot(1, a_Player);
+ char NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
+ if (NumFit <= 0)
+ {
+ // Full stack already
+ return;
+ }
+ NumFit = std::min(NumFit, a_ItemStack.m_ItemCount);
+
+ if (a_Apply)
+ {
+ cItem NewSlot(a_ItemStack);
+ NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit;
+ SetSlot(1, a_Player, NewSlot);
+ }
+ a_ItemStack.m_ItemCount -= NumFit;
+ // Return so we don't put overflow into the enchantment slot
+ return;
+ }
const cItem * Slot = GetSlot(0, a_Player);
if (!Slot->IsEmpty())
{