summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 07e91f59a..c7805e4de 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -2729,4 +2729,27 @@ void cClientHandle::SocketClosed(void)
+void cClientHandle::HandleEnchantItem(Byte & WindowID, Byte & Enchantment)
+{
+ cEnchantingWindow * Window = (cEnchantingWindow*)m_Player->GetWindow();
+ cItem Item = *Window->m_SlotArea->GetSlot(0, *m_Player);
+ int BaseEnchantmentLevel = Window->GetPropertyValue(Enchantment);
+
+ if (Item.EnchantByXPLevels(BaseEnchantmentLevel))
+ {
+ if (m_Player->IsGameModeCreative() || m_Player->DeltaExperience(-m_Player->XpForLevel(BaseEnchantmentLevel)) >= 0)
+ {
+ Window->m_SlotArea->SetSlot(0, *m_Player, Item);
+ Window->SendSlot(*m_Player, Window->m_SlotArea, 0);
+ Window->BroadcastWholeWindow();
+
+ Window->SetProperty(0, 0, *m_Player);
+ Window->SetProperty(1, 0, *m_Player);
+ Window->SetProperty(2, 0, *m_Player);
+ }
+ }
+}
+
+
+