diff --git a/minecraft/networking/modern.py b/minecraft/networking/modern.py index 6eb7355..678ffcc 100644 --- a/minecraft/networking/modern.py +++ b/minecraft/networking/modern.py @@ -831,6 +831,13 @@ class SetCarriedItemPacket(Packet): definition = [{'slot': Short}] +class SetHeldSlotPacket(Packet): + """Server synchronization of the selected hotbar slot (protocol 777).""" + id = 0x6B + packet_name = "set held slot" + definition = [{'slot': VarInt}] + + class ContainerClickSwapPacket(Packet): id = 0x12 packet_name = "container click swap" @@ -1134,7 +1141,7 @@ class ModernPlayingReactor(PacketReactor): EntityPositionSyncPacket, PlayerInfoUpdatePacket, PlayerInfoRemovePacket, ContainerOpenPacket, ContainerSetContentPacket, ContainerSetSlotPacket, - SetCursorItemPacket, + SetCursorItemPacket, SetHeldSlotPacket, } def react(self, packet): diff --git a/tests/test_modern_chunk_packets.py b/tests/test_modern_chunk_packets.py index 4448c6e..3fd4a00 100644 --- a/tests/test_modern_chunk_packets.py +++ b/tests/test_modern_chunk_packets.py @@ -2,7 +2,14 @@ import struct import unittest from io import BytesIO -from minecraft.networking.modern import ForgetChunkPacket +from minecraft.networking.modern import ForgetChunkPacket, SetHeldSlotPacket + + +class TestSetHeldSlotPacket(unittest.TestCase): + def test_reads_server_selected_hotbar_slot(self): + packet = SetHeldSlotPacket() + packet.read(BytesIO(bytes([2]))) + self.assertEqual(packet.slot, 2) class TestForgetChunkPacket(unittest.TestCase):