From 0c2b307eab67b7f37d82a7862a6acbcd96b45adb Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Mon, 20 Jan 2014 18:22:08 +0100 Subject: first changes for enchanting (not finished) - added enchanting table block handler and added it to the blockhandler - added enchanting window - drop item in the slot 0 when the player close the window - added enchanting packet (1.7 only) - some more... --- src/UI/Window.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/UI/Window.cpp') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 3ffeff7a0..fcfe6faf3 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -781,6 +781,21 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cEnchantingWindow: + +cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : +cWindow(wtEnchantment, "Enchantment Table") +{ + m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this)); + m_SlotAreas.push_back(new cSlotAreaInventory(*this)); + m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cChestWindow: -- cgit v1.2.3 From bfac00f2807a6740e876adebd689cc3ae6e075ed Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Fri, 24 Jan 2014 20:01:21 +0100 Subject: Some updates for enchanting --- src/UI/Window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/UI/Window.cpp') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index fcfe6faf3..9188b47a7 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -785,7 +785,7 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : // cEnchantingWindow: cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : -cWindow(wtEnchantment, "Enchantment Table") +cWindow(wtEnchantment, "Enchant") { m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); -- cgit v1.2.3 From e6e702e7fdbc8b7475d3dbecc0f81a08304997ae Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 12 Apr 2014 14:58:46 +0200 Subject: Added complete Enchanting System http://minecraft.gamepedia.com/Enchantment_mechanics --- src/UI/Window.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) (limited to 'src/UI/Window.cpp') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 5d89534dd..c514e76e7 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -808,7 +808,10 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : // cEnchantingWindow: cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : -cWindow(wtEnchantment, "Enchant") + cWindow(wtEnchantment, "Enchant"), + m_BlockX(a_BlockX), + m_BlockY(a_BlockY), + m_BlockZ(a_BlockZ) { m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); @@ -819,6 +822,87 @@ cWindow(wtEnchantment, "Enchant") +void cEnchantingWindow::SetProperty(int a_Property, int a_Value) +{ + if (a_Property == 0) + { + m_PropertyValue0 = a_Value; + } + else if (a_Property == 1) + { + m_PropertyValue1 = a_Value; + } + else if (a_Property == 2) + { + m_PropertyValue2 = a_Value; + } + + cCSLock Lock(m_CS); + for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr) + { + (*itr)->GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value); + } // for itr - m_OpenedBy[] +} + + + + + +void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player) +{ + if (a_Property == 0) + { + m_PropertyValue0 = a_Value; + } + else if (a_Property == 1) + { + m_PropertyValue1 = a_Value; + } + else if (a_Property == 2) + { + m_PropertyValue2 = a_Value; + } + + a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value); +} + + + + + +int cEnchantingWindow::GetPropertyValue(int a_Property) +{ + if (a_Property == 0) + { + return m_PropertyValue0; + } + else if (a_Property == 1) + { + return m_PropertyValue1; + } + else if (a_Property == 2) + { + return m_PropertyValue2; + } + + return -1; +} + + + + + +void cEnchantingWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ) +{ + a_PosX = m_BlockX; + a_PosY = m_BlockY; + a_PosZ = m_BlockZ; +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cChestWindow: -- cgit v1.2.3 From e81fc2779e4b9a8ce847d63864537259033c9cb9 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 15 Apr 2014 21:10:44 +0200 Subject: Add more checks to cSlotAreaEnchanting --- src/UI/Window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/UI/Window.cpp') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index c514e76e7..c7b9b6aaf 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -813,7 +813,7 @@ cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : m_BlockY(a_BlockY), m_BlockZ(a_BlockZ) { - m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this)); + m_SlotAreas.push_back(new cSlotAreaEnchanting(*this)); m_SlotAreas.push_back(new cSlotAreaInventory(*this)); m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); } -- cgit v1.2.3 From f9343a8490b50cb28a62c7327c0013da48ca2745 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Thu, 17 Apr 2014 13:15:35 +0200 Subject: Modified many things --- src/UI/Window.cpp | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) (limited to 'src/UI/Window.cpp') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index c7b9b6aaf..fffe0e3fd 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -824,18 +824,7 @@ cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) : void cEnchantingWindow::SetProperty(int a_Property, int a_Value) { - if (a_Property == 0) - { - m_PropertyValue0 = a_Value; - } - else if (a_Property == 1) - { - m_PropertyValue1 = a_Value; - } - else if (a_Property == 2) - { - m_PropertyValue2 = a_Value; - } + m_PropertyValue[a_Property] = a_Value; cCSLock Lock(m_CS); for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr) @@ -850,18 +839,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value) void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player) { - if (a_Property == 0) - { - m_PropertyValue0 = a_Value; - } - else if (a_Property == 1) - { - m_PropertyValue1 = a_Value; - } - else if (a_Property == 2) - { - m_PropertyValue2 = a_Value; - } + m_PropertyValue[a_Property] = a_Value; a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value); } @@ -872,20 +850,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Pla int cEnchantingWindow::GetPropertyValue(int a_Property) { - if (a_Property == 0) - { - return m_PropertyValue0; - } - else if (a_Property == 1) - { - return m_PropertyValue1; - } - else if (a_Property == 2) - { - return m_PropertyValue2; - } - - return -1; + return m_PropertyValue[a_Property]; } -- cgit v1.2.3 From a6de7bf1cd80847abed22e3b962a5b8650b2911c Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Sat, 19 Apr 2014 15:10:50 +0200 Subject: Fixed Code --- src/UI/Window.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/UI/Window.cpp') diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index fffe0e3fd..0a78578fc 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -826,11 +826,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value) { m_PropertyValue[a_Property] = a_Value; - cCSLock Lock(m_CS); - for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr) - { - (*itr)->GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value); - } // for itr - m_OpenedBy[] + super::SetProperty(a_Property, a_Value); } @@ -841,7 +837,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Pla { m_PropertyValue[a_Property] = a_Value; - a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value); + super::SetProperty(a_Property, a_Value, a_Player); } -- cgit v1.2.3