summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authordaniel0916 <theschokolps@gmail.com>2014-01-31 19:46:51 +0100
committerdaniel0916 <theschokolps@gmail.com>2014-01-31 19:46:51 +0100
commit36120db400691be75199ff404e35f5c289b8818f (patch)
tree0547d366be14b96a961331de0f93ae86ff0fa4ae /src/Protocol
parentremoved hook from enchanting commit (diff)
downloadcuberite-36120db400691be75199ff404e35f5c289b8818f.tar
cuberite-36120db400691be75199ff404e35f5c289b8818f.tar.gz
cuberite-36120db400691be75199ff404e35f5c289b8818f.tar.bz2
cuberite-36120db400691be75199ff404e35f5c289b8818f.tar.lz
cuberite-36120db400691be75199ff404e35f5c289b8818f.tar.xz
cuberite-36120db400691be75199ff404e35f5c289b8818f.tar.zst
cuberite-36120db400691be75199ff404e35f5c289b8818f.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol125.cpp15
-rw-r--r--src/Protocol/Protocol125.h1
-rw-r--r--src/Protocol/Protocol17x.cpp17
-rw-r--r--src/Protocol/Protocol17x.h2
4 files changed, 21 insertions, 14 deletions
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index 323a13992..b2b61acc9 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -1535,6 +1535,21 @@ int cProtocol125::ParseUseEntity(void)
+int cProtocol125::ParseEnchantItem(void)
+{
+ HANDLE_PACKET_READ(ReadByte, byte, WindowID);
+ HANDLE_PACKET_READ(ReadByte, byte, Enchantment);
+
+ // TODO: Enchant Handling for older Protocols
+
+
+ return PARSE_OK;
+}
+
+
+
+
+
int cProtocol125::ParseWindowClick(void)
{
HANDLE_PACKET_READ(ReadChar, char, WindowID);
diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h
index 310f9dd78..e3c8765b1 100644
--- a/src/Protocol/Protocol125.h
+++ b/src/Protocol/Protocol125.h
@@ -133,6 +133,7 @@ protected:
virtual int ParseSlotSelected (void);
virtual int ParseUpdateSign (void);
virtual int ParseUseEntity (void);
+ virtual int ParseEnchantItem (void);
virtual int ParseWindowClick (void);
virtual int ParseWindowClose (void);
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 949498734..05b7ebd45 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1143,7 +1143,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
case 0x0e: HandlePacketWindowClick (a_ByteBuffer); return true;
case 0x0f: // Confirm transaction - not used in MCS
case 0x10: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true;
- case 0x11: HandlePacketEnchanting (a_ByteBuffer); return true;
+ case 0x11: HandlePacketEnchantItem (a_ByteBuffer); return true;
case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true;
case 0x13: HandlePacketPlayerAbilities (a_ByteBuffer); return true;
case 0x14: HandlePacketTabComplete (a_ByteBuffer); return true;
@@ -1546,23 +1546,14 @@ void cProtocol172::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer)
-void cProtocol172::HandlePacketEnchanting(cByteBuffer & a_ByteBuffer)
+void cProtocol172::HandlePacketEnchantItem(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, WindowID);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Enchantment);
- LOGWARN("Enchantment Packet received!");
+ LOGWARN("Protocol 1.7: Enchantment Packet received!");
- //Get Item from Window Slot
- cItem EnchantItem = *m_Client->GetPlayer()->GetWindow()->GetSlot(*m_Client->GetPlayer(), 0);
-
- //Enchant item with Sharpness 5
- EnchantItem.m_Enchantments.SetLevel(cEnchantments::enchSharpness, 5);
-
- //Set Enchanted Item to Window Slot
- m_Client->GetPlayer()->GetWindow()->SetSlot(*m_Client->GetPlayer(), 0, EnchantItem);
-
- LOGWARN("Item enchanted!");
+ m_Client->HandleEnchantItem(WindowID, Enchantment);
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 7877e783a..1f3039edb 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -258,7 +258,7 @@ protected:
void HandlePacketTabComplete (cByteBuffer & a_ByteBuffer);
void HandlePacketUpdateSign (cByteBuffer & a_ByteBuffer);
void HandlePacketUseEntity (cByteBuffer & a_ByteBuffer);
- void HandlePacketEnchanting (cByteBuffer & a_ByteBuffer);
+ void HandlePacketEnchantItem (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer);