Decode 26.3 block entity data packets
This commit is contained in:
1 parent
46b27f4b94
commit
a48b366b09
2 files changed
+46
-2
No files matched your search
@@ -2,7 +2,7 @@ import io
|
||||
import unittest
|
||||
|
||||
from minecraft.networking.modern import (
|
||||
ModernPlayingReactor, SetEntityDataPacket,
|
||||
BlockEntityDataPacket, ModernPlayingReactor, SetEntityDataPacket,
|
||||
)
|
||||
|
||||
|
||||
@@ -16,6 +16,26 @@ def encode_varint(value):
|
||||
|
||||
|
||||
class EntityMetadataPacketTests(unittest.TestCase):
|
||||
def test_block_entity_data_packet_decodes_sign_location_and_is_registered(self):
|
||||
x, y, z = 5, 64, -3
|
||||
packed_position = ((x & 0x3FFFFFF) << 38 |
|
||||
(z & 0x3FFFFFF) << 12 | (y & 0xFFF))
|
||||
payload = (packed_position.to_bytes(8, 'big') +
|
||||
encode_varint(7) + bytes((0,)))
|
||||
class Context:
|
||||
@staticmethod
|
||||
def protocol_later_eq(_version):
|
||||
return True
|
||||
|
||||
packet = BlockEntityDataPacket(context=Context())
|
||||
packet.read(io.BytesIO(payload))
|
||||
|
||||
self.assertEqual((packet.location.x, packet.location.y,
|
||||
packet.location.z), (x, y, z))
|
||||
self.assertEqual(packet.block_entity_type, 7)
|
||||
self.assertIn(BlockEntityDataPacket,
|
||||
ModernPlayingReactor.get_clientbound_packets(None))
|
||||
|
||||
def test_item_stack_metadata_decodes_and_is_registered(self):
|
||||
entity_id = 42
|
||||
item_id = 86
|
||||
|
||||
Reference in new issue
Block a user