From bea661860d8f5ce09d3a1af074eb10f219610068 Mon Sep 17 00:00:00 2001 From: Amund Eggen Svandal Date: Wed, 2 Jan 2019 00:53:41 +0100 Subject: [PATCH] Add Use Item packet --- .../packets/serverbound/play/__init__.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/minecraft/networking/packets/serverbound/play/__init__.py b/minecraft/networking/packets/serverbound/play/__init__.py index 97d5604..01159d5 100644 --- a/minecraft/networking/packets/serverbound/play/__init__.py +++ b/minecraft/networking/packets/serverbound/play/__init__.py @@ -21,6 +21,7 @@ def get_packets(context): ClientSettingsPacket, PluginMessagePacket, PlayerBlockPlacementPacket, + UseItemPacket, } if context.protocol_version >= 107: packets |= { @@ -197,3 +198,22 @@ class PlayerBlockPlacementPacket(Packet): # PlayerBlockPlacementPacket.Face is an alias for BlockFace. Face = BlockFace + + +class UseItemPacket(Packet): + @staticmethod + def get_id(context): + return 0x2A if context.protocol_version >= 389 else \ + 0x28 if context.protocol_version >= 386 else \ + 0x20 if context.protocol_version >= 345 else \ + 0x1F if context.protocol_version >= 343 else \ + 0x20 if context.protocol_version >= 332 else \ + 0x1F if context.protocol_version >= 318 else \ + 0x1D + + packet_name = "use item" + get_definition = staticmethod(lambda context: [ + {'hand': VarInt}]) + + Hand = RelativeHand + HAND_MAIN, HAND_OFF = Hand.MAIN, Hand.OFF # For backward compatibility.