summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
authordaniel0916 <theschokolps@gmail.com>2014-04-07 19:52:35 +0200
committerdaniel0916 <theschokolps@gmail.com>2014-04-07 19:52:35 +0200
commitaf566d5a79134842854bea78de577676d507949f (patch)
tree8ab441598a88aaea3163b19ace2b341471e8e273 /src/UI
parentadded EnchantItemPacket to older Protocols (diff)
downloadcuberite-af566d5a79134842854bea78de577676d507949f.tar
cuberite-af566d5a79134842854bea78de577676d507949f.tar.gz
cuberite-af566d5a79134842854bea78de577676d507949f.tar.bz2
cuberite-af566d5a79134842854bea78de577676d507949f.tar.lz
cuberite-af566d5a79134842854bea78de577676d507949f.tar.xz
cuberite-af566d5a79134842854bea78de577676d507949f.tar.zst
cuberite-af566d5a79134842854bea78de577676d507949f.zip
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/SlotArea.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index a226d027b..03bfd275a 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -13,6 +13,8 @@
#include "Window.h"
#include "../CraftingRecipes.h"
#include "../Root.h"
+#include "../FastRandom.h"
+#include "../BlockArea.h"
@@ -615,23 +617,31 @@ void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
if (a_Player.GetDraggingItem().IsEmpty())
{
LOGWARN("EMPTY");
- this->m_ParentWindow.SetProperty(0, 0);
- this->m_ParentWindow.SetProperty(1, 0);
- this->m_ParentWindow.SetProperty(2, 0);
+ m_ParentWindow.SetProperty(0, 0);
+ m_ParentWindow.SetProperty(1, 0);
+ m_ParentWindow.SetProperty(2, 0);
}
else if (a_Player.GetDraggingItem().IsEnchantable)
{
+ int bookshelves = 15; // TODO: Check Bookshelves
+
+ cFastRandom Random;
+ int base = (Random.GenerateRandomInteger(1, 8) + floor(bookshelves / 2) + Random.GenerateRandomInteger(0, bookshelves));
+ int topSlot = std::max(base / 3, 1);
+ int middleSlot = (base * 2) / 3 + 1;
+ int bottomSlot = std::max(base, bookshelves * 2);
+
LOGWARN("Enchantable");
- this->m_ParentWindow.SetProperty(0, 30);
- this->m_ParentWindow.SetProperty(1, 20);
- this->m_ParentWindow.SetProperty(2, 10);
+ m_ParentWindow.SetProperty(0, topSlot);
+ m_ParentWindow.SetProperty(1, middleSlot);
+ m_ParentWindow.SetProperty(2, bottomSlot);
}
else
{
LOGWARN("Not Enchantable");
- this->m_ParentWindow.SetProperty(0, 0);
- this->m_ParentWindow.SetProperty(1, 0);
- this->m_ParentWindow.SetProperty(2, 0);
+ m_ParentWindow.SetProperty(0, 0);
+ m_ParentWindow.SetProperty(1, 0);
+ m_ParentWindow.SetProperty(2, 0);
}
}