Decode selected hotbar slot updates

This commit is contained in:
Tanner committed 2026-11-05 02:59:56 +00:00
1 parent 9cd9aef05f
commit 0e3b556628
2 files changed
+16 -2

No files matched your search

+8 -1
View File
@@ -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):
+8 -1
View File
@@ -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):