diff options
author | 9caihezi <9caihezi@gmail.com> | 2018-01-08 14:37:10 +0100 |
---|---|---|
committer | peterbell10 <peterbell10@live.co.uk> | 2018-01-08 14:37:10 +0100 |
commit | 4242431407459e91f725de9cb7fb1e2ffade216d (patch) | |
tree | 620e7f525183c768bee8014fae7e08ed61089b92 /src/Protocol/Protocol_1_9.cpp | |
parent | readme: Be explicit that Cuberite works with Java Edition Clients. (#4138) (diff) | |
download | cuberite-4242431407459e91f725de9cb7fb1e2ffade216d.tar cuberite-4242431407459e91f725de9cb7fb1e2ffade216d.tar.gz cuberite-4242431407459e91f725de9cb7fb1e2ffade216d.tar.bz2 cuberite-4242431407459e91f725de9cb7fb1e2ffade216d.tar.lz cuberite-4242431407459e91f725de9cb7fb1e2ffade216d.tar.xz cuberite-4242431407459e91f725de9cb7fb1e2ffade216d.tar.zst cuberite-4242431407459e91f725de9cb7fb1e2ffade216d.zip |
Diffstat (limited to 'src/Protocol/Protocol_1_9.cpp')
-rw-r--r-- | src/Protocol/Protocol_1_9.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index 2b66cc7fa..3e600cefd 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -66,6 +66,7 @@ static const Int16 SLOT_NUM_OUTSIDE = -999; /** Value for main hand in Hand parameter for Protocol 1.9. */ static const UInt32 MAIN_HAND = 0; +static const UInt32 OFF_HAND = 1; @@ -2384,7 +2385,7 @@ void cProtocol_1_9_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorX); HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorY); HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorZ); - m_Client->HandleRightClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), CursorX, CursorY, CursorZ, m_Client->GetPlayer()->GetEquippedItem()); + m_Client->HandleRightClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), CursorX, CursorY, CursorZ, HandIntToEnum(Hand)); } @@ -2784,10 +2785,9 @@ void cProtocol_1_9_0::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer) void cProtocol_1_9_0::HandlePacketUseItem(cByteBuffer & a_ByteBuffer) { - HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt64, Hand); + HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Hand); - // Didn't click a block - emulate old values used with place block of -1, -1, -1 (and BLOCK_FACE_NONE). - m_Client->HandleRightClick(-1, 255, -1, BLOCK_FACE_NONE, 0, 0, 0, m_Client->GetPlayer()->GetEquippedItem()); + m_Client->HandleUseItem(HandIntToEnum(Hand)); } @@ -3267,6 +3267,25 @@ eBlockFace cProtocol_1_9_0::FaceIntToBlockFace(Int32 a_BlockFace) +eHand cProtocol_1_9_0::HandIntToEnum(Int32 a_Hand) +{ + // Convert hand parameter into eHand enum + switch (a_Hand) + { + case MAIN_HAND: return eHand::hMain; + case OFF_HAND: return eHand::hOff; + default: + { + ASSERT(!"Unknown hand value"); + return eHand::hMain; + } + } +} + + + + + //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_9_0::cPacketizer: |