diff --git a/minecraft/networking/packets/clientbound/play/__init__.py b/minecraft/networking/packets/clientbound/play/__init__.py index 3624357..1afe9f6 100644 --- a/minecraft/networking/packets/clientbound/play/__init__.py +++ b/minecraft/networking/packets/clientbound/play/__init__.py @@ -240,14 +240,14 @@ class EntityPositionDeltaPacket(Packet): ] # The following transforms are retained for backward compatibility; - # they represent the delta values as fixed-point integers with 5 bits + # they represent the delta values as fixed-point integers with 12 bits # of fractional part, regardless of the protocol version. - delta_x = attribute_transform('delta_x_float', lambda x: int(x * 32), - lambda x: x / 32) - delta_y = attribute_transform('delta_y_float', lambda y: int(y * 32), - lambda y: y / 32) - delta_z = attribute_transform('delta_z_float', lambda z: int(z * 32), - lambda z: z / 32) + delta_x = attribute_transform( + 'delta_x_float', lambda x: int(x * 4096), lambda x: x / 4096) + delta_y = attribute_transform( + 'delta_y_float', lambda y: int(y * 4096), lambda y: y / 4096) + delta_z = attribute_transform( + 'delta_z_float', lambda z: int(z * 4096), lambda z: z / 4096) class TimeUpdatePacket(Packet): diff --git a/tests/test_backward_compatible.py b/tests/test_backward_compatible.py index 023114f..c9cc66c 100644 --- a/tests/test_backward_compatible.py +++ b/tests/test_backward_compatible.py @@ -163,12 +163,12 @@ class ClassMemberAliasesTest(unittest.TestCase): def test_entity_position_delta_packet(self): packet = clientbound.play.EntityPositionDeltaPacket() - packet.delta_x = -128 + packet.delta_x = -32768 packet.delta_y = 33 - packet.delta_z = 127 - self.assertEqual(packet.delta_x_float, -4.0) - self.assertEqual(packet.delta_y_float, 1.03125) - self.assertEqual(packet.delta_z_float, 3.96875) - self.assertEqual(packet.delta_x, -128) + packet.delta_z = 32767 + self.assertEqual(packet.delta_x_float, -8.0) + self.assertEqual(packet.delta_y_float, 0.008056640625) + self.assertEqual(packet.delta_z_float, 7.999755859375) + self.assertEqual(packet.delta_x, -32768) self.assertEqual(packet.delta_y, 33) - self.assertEqual(packet.delta_z, 127) + self.assertEqual(packet.delta_z, 32767)